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
Does std endl flush?
How do I exit turbo c++?
What are the different types of comments allowed in c++?
What is abstraction c++?
Does dev c++ support c++ 11?
What can c++ be used for?
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
How to declare an array of pointers to integer?
Can we delete this pointer in c++?
What is c++ iterator?
Write a program in c++ to print the numbers from n to n2 except 5 and its multiples
What is a c++ class?
How do you flush a buffer in c++?
How does the copy constructor differ from the assignment operator (=)?
What is #include iostream h in c++?