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 ?    72 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 ?    99 Yes 70 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 ?    14 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 / krishna krish

0 1 2 3 4

Is This Answer Correct ?    6 Yes 5 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 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 / ramveer

for the first loop i is 0 so 0 is printed
for 2nd time i++ i becomes 1 so 1 is printed
for 3rd time i becomes 2 so 2 gets printed
for 4th time i becomes 3 so it gets prited
for 5th time i becomes 4 so it gets printed
now for this time i has became 5 and this isn't in loop boudary as the condition is i<5 so its breaks out of loop.

so the ans is "0 1 2 3 4" .

Is This Answer Correct ?    9 Yes 9 No

Post New Answer



More C C++ Errors Interview Questions

2. A student studying Information Technology at Polytechnic of Namibia is examined by coursework and written examination. Both components of assessment carry a maximum of 50 marks. The following rules are used by examiners in order to pass or fail students. a. A student must score a total of 40% or more in order to pass (total = coursework marks + examination marks) b. A total mark of 39% is moderated to 40% c. Each component must be passed with a minimum mark of 20/50. If a student scores a total of 40% or more but does not achieve the minimum mark in either component he/she is given a technical fail of 39% (this mark is not moderated to 40%) d. Grades are awarded on marks that fall into the following categories. Mark 100-70 69-60 59-50 49-40 39-0 Grade A B C D E Write a program to input the marks for both components (coursework marks out of 50 and examination marks out of 50), out put the final mark and grade after any moderation. [30]

0 Answers  


main() { char c; for(c='A';c<='Z';c++) getch(); }

9 Answers  


Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0. Instructor's notes: This problem requires either a while or a do-while loop.

3 Answers  


errors are known as?

3 Answers   State Bank Of India SBI, EX,


Write down the difference between c. Loop and goto statement d. (!0) and (!1) e. (1= =! 1) and (1!=1) f. NULL and !NULL

0 Answers  






How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?

1 Answers  


How to convert hexadecimal to binary using c language..

1 Answers   GAIL, Satyam, Bajaj, Zenqa,


write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;

0 Answers  


how to convert decimal to hexadecimal without using arrays just loops

2 Answers  


what is syntax error?

3 Answers  


how tally is useful?

2 Answers  


What is probability to guarantee that the task a programmer is going to create will be created and be able to run on a particular system (RTOS/GPOS).

0 Answers  






Categories