int main()
{
int i ,a[i];
i = 0;
a[i] = 10;
cout<< a[i] << endl;
return 0;
}
What will be output of this program?
Answer Posted / rajesh
It will give segmentation fault(core dumped) - runtime error
This is not the way of declaring an array...a slight change
in program can correct it. Code below...
int main()
{
int i=0 ,a[i];
// i = 0;
a[i] = 10;
cout<< a[i] << endl;
return 0;
}
output : 10
please initialise the value of i before putting it in array
a[i]..this code will work fine and will give the output as 10.
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is c++ programming language?
What are vectors used for in c++?
What are different types of loops in c++?
What is a block in c++?
What is a vector c++?
When must you use a pointer rather than a reference?
Can manipulators fall in love?
Explain the use of vtable.
What problems might the following macro bring to the application?
If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?
What are the operators in c++?
Do you know what are static and dynamic type checking?
Describe the syntax of single inheritance in C++?
Explain the difference between struct and class in terms of access modifier.
If a header file is included twice by mistake in the program, will it give any error?