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
Explain the auto storage classes in c++.
Describe about storage allocation and scope of global, extern, static, local and register variables?
Can turbo c++ run c program?
Can you explicitly call a destructor on a local variable?
Can constructor be static in c++?
What can c++ be used for?
Write a note about the virtual member function?
What are vectors used for in c++?
Describe friend function & its advantages.
What is & in c++ function?
What is the real purpose of class – to export data?
When you overload member functions, in what ways must they differ?
Are there interfaces in c++?
Will rust take over c++?
How can I disable the "echo" feature?