void main()
{
for(int i=0;i<5;i++);
printf("%d",i);
}

What is the output?..




Answers were Sorted based on User's Feedback



void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / kumaran

declaring int i inside for loop is not available in
traditional 'c'

Is This Answer Correct ?    73 Yes 22 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / mariaalex007

Answer is 5..........

Is This Answer Correct ?    102 Yes 71 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / mahfooz

we can not declare loop condition variable in c..we can do
in c++.

Is This Answer Correct ?    35 Yes 16 No




void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / samir isakoski

why shoul have a cout if is c++

buth this is c (printf)

and why cannot daclare a int in the for ciclus

Is This Answer Correct ?    17 Yes 7 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / divya

no output because the for loop is terminated with a semicolon which means the loop will terminate at once.

Is This Answer Correct ?    15 Yes 9 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / ricky dobriyal

hi friend i am ricky dobriyal.
if this programe in c then this program produce error
expression syntex error.
if in c++ then it will produce o/p=5

Is This Answer Correct ?    9 Yes 6 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / radha raman

output=5

Is This Answer Correct ?    2 Yes 1 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / pramod

if it is in C it displays an error "indicating that "i"
cannot be declared in loop and i as undefined symbol"

if it the case of C++ it displays "5" because C++ supports
dynamic declaration and once declared anywhere in the
program(even in loops) can be used anytime in that program

Is This Answer Correct ?    1 Yes 1 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / avi

Error will occur

Is This Answer Correct ?    2 Yes 2 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / sansiri

the answer is...........0




because in c,c++ program when the semicolon is present then it is considered as one statement
here for loop has a semicolon so it consider one statement and execute only one so that the initial value o is printed

Is This Answer Correct ?    0 Yes 0 No

Post New Answer



More C C++ Errors Interview Questions

what is run time error?

7 Answers  


write a profram for selection sort whats the error in it?

2 Answers  


void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..

31 Answers   CTS, iGate, HCL, College School Exams Tests, SmartData,


How to reverse a linked list without using array & -1? Thank you.

2 Answers   Satyam, Access,


How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

0 Answers  






what is the large sustained error signal that eventually cause the controller output to drive to its limit

1 Answers   TCS,


which typw of errors ? & how to solve it ?

0 Answers  


Given that two int variables, total and amount , have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount , one at a time. After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). Instructor's notes: If you use a loop, it must be a for loop. And if you use a loop control variable for counting, you must declare it.

1 Answers   Google,


wap for bubble sort

3 Answers  


difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?

2 Answers   TCS,


Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

2 Answers  


when i use cout or cin call & then either << or >> .....it shows declaration syntax error...what should i do? cout<<"anything"; int a; cin>>a; return 0;

2 Answers  






Categories