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
How did c++ get its name?
Declare a class vehicle and make it an abstract data type.
What is the use of data hiding?
Explain what are accessor methods?
What is time h in c++?
What is buffer and example?
What is the use of typedef?
How much do c++ programmers make?
Write a program in C++ for Fibonacci series
What are the advantages of inheritance in c++?
Search for: what is pair in c++?
How important is c++?
Explain the use of this pointer?
Which is best ide for c++?
What is else if syntax?