int main()
{
int i ,a[i];
i = 0;
a[i] = 10;
cout<< a[i] << endl;
return 0;


}

What will be output of this program?

Answers were Sorted based on User's Feedback



int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / sachinmundhra

This will not get compile.

int i , a[i] ; // This statement will given error. Constant
expression required.

Is This Answer Correct ?    38 Yes 3 No

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / kamal

10

Is This Answer Correct ?    30 Yes 9 No

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / ravinder kumar(omnietysolution

Error in program

Is This Answer Correct ?    10 Yes 3 No

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / ramesh kumar

in array we can must enter size integer...
not as variable type like i
thats why it gives an error

Is This Answer Correct ?    9 Yes 2 No

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / mohammed afroz

There are compile time error in this program. Because array
can declare with a constant value.

Is This Answer Correct ?    7 Yes 2 No

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / vikas

Index variable of any array should be integer constant.
but in this case i is not constant so it is a error

Is This Answer Correct ?    5 Yes 1 No

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / ramez

Constant expression will be required here...

Is This Answer Correct ?    4 Yes 1 No

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / 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

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / blacky

Compiler will Core Dump

Is This Answer Correct ?    2 Yes 2 No

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } ..

Answer / anil hooda

it will return any integer value.....

Is This Answer Correct ?    1 Yes 9 No

Post New Answer

More C++ General Interview Questions

When do we run a shell in the unix system? How will you tell which shell you are running?

0 Answers  


How are virtual functions implemented in c++?

0 Answers  


What is c++ manipulator?

0 Answers  


How many ways are there to initialize an int with a constant?

1 Answers  


Write a program which employs Recursion

0 Answers  






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

0 Answers   Impetus,


What is Name Decoration?

2 Answers   Lucent,


Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- &#9474; &#9474; &#9474; &#9474; &#9474; &#9474; ---

0 Answers  


What is null pointer and void pointer?

0 Answers  


What is the difference between ++ count and count ++?

0 Answers  


What is the difference between containment and delegation?

0 Answers  


Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened

0 Answers  


Categories