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


Please Help Members By Posting Answers For Below Questions

What is the latest c++ standard?

684


What is the use of dot in c++?

622


What is an adaptor class in c++?

602


How do we balance an AVL Tree in C++?

639


What is the rule of three?

572






What are the basics of local (auto) objects?

634


Describe the advantage of an external iterator.

620


What is protected inheritance?

599


What do you mean by overhead in c++?

580


In a function declaration, what does extern mean?

638


Why are pointers not used in c++?

628


What are proxy objects in c++?

643


Is c++ high level programming language?

675


What are member functions used in c++?

560


Explain how an exception handler is defined and invoked in a Program.

584