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 the latest c++ standard?
What is the use of dot in c++?
What is an adaptor class in c++?
How do we balance an AVL Tree in C++?
What is the rule of three?
What are the basics of local (auto) objects?
Describe the advantage of an external iterator.
What is protected inheritance?
What do you mean by overhead in c++?
In a function declaration, what does extern mean?
Why are pointers not used in c++?
What are proxy objects in c++?
Is c++ high level programming language?
What are member functions used in c++?
Explain how an exception handler is defined and invoked in a Program.