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 does the following statement mean? int (*a)[4]
What is searching? Explain linear and binary search.
What is a list c++?
Describe linkages and types of linkages?
What's the order in which the local objects are destructed?
What is stoi in c++?
Should you pass exceptions by value or by reference?
Why c++ is faster than java?
How does atoi function work?
Describe new operator and delete operator?
If a function doesn’t return a value, how do you declare the function?
Can we make copy constructor private in c++?
What do you mean by public protected and private in c++?
Explain the difference between new() and malloc() in c++?
Is map sorted c++?