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

What is the difference between the functions memmove() and memcpy()?

0 Answers  


How the endl and setw manipulator works?

0 Answers  


What is prototype for that c string function?

0 Answers  


what is an array

20 Answers  


Write a program to read the data and evaluate the results of the election. Print all output to the screen. Your output should specify: The total number of votes, the number of valid votes and the number of spoilt votes. The winner(s) of the election. Hint: An appropriate search should be used to determine the winner(s). The votes obtained by each candidate sorted in terms of the number of votes obtained. Hint: An appropriate sort should be used to sort the candidate(s). The Source code should be saved as VotingSystem. Project Input: Candidates’ Names and Numbers 2501 Victor Taylor 2502 Denise Duncan 2503 Kamal Ramdhan 2504 Michael Ali 2505 Anisa Sawh 2506 Carol Khan 2507 Gary Owen Votes 3 1 2 5 4 3 5 3 5 3 2 8 1 6 7 7 3 5 6 9 3 4 7 1 2 4 5 5 1 4 0 Project Output: Invalid vote: 8 Invalid vote: 9 Number of voters: 30 Number of valid votes: 28 Number of spoilt votes: 2 The winner(s): 2503 Kamal Ramdhan 2505 Anisa Sawh Candidate Score 2503 Kamal Ramdhan 6 2505 Anisa Sawh 6 2501 Victor Taylor 4 2504 Michael Ali 4 2502 Denise Duncan 3 2507 Gary Owen 3 2506 Carol Khan 2

0 Answers  


Design a program to input a date from user in the form day/month/year (e.g. 2/6/2000) and report whether it’s a valid date or not. The program should take account of leap years. You will need to know that a leap year is a year that is exactly divisible by 4, except that century years are only leap years if they are divisible by 400.

1 Answers  


Can constructor be private in c++?

0 Answers  


What are the conditions that have to be met for a condition to be an invariant of the class?

1 Answers  


Using a smart pointer can we iterate through a container?

0 Answers  


What are different types of typecasting supported by C++

1 Answers   CA,


What are the three forms of cin.get() and what are their differences?

0 Answers  


What's the "software peter principle”?

0 Answers  


Categories