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

0
1
2
3
4

Is This Answer Correct ?    0 Yes 1 No

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

Answer / gsravya

It will be 0,1,2,3,4

Is This Answer Correct ?    0 Yes 1 No

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

Answer / ish

0
1
2
3
4

Is This Answer Correct ?    2 Yes 4 No

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

Answer / sudeshna

it is a declaration error.
since we declared variable i in the for-loop
and the for-loop is terminated by a semi-colon
so it cannot be accessed outside the for-loop

Is This Answer Correct ?    0 Yes 2 No

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

Answer / suggest

it will report error....
bcoz, integer variable i have scope inside the for loop only....
we cant access it in printf....bcoz for loop have one semicolon

Is This Answer Correct ?    0 Yes 2 No

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

Answer / medo

It's 5...if this is in the condition.(case 1)
But if the condition i<=5,the output will be 6.(case 2)
So the hand trace for the cace 1:

Memory__ |_|_|_|___|
i =0 |1|2|3|4|(5)|
i++ =1 |2|3|4|5| - |
it will print 5.

_-_-_-_-_-_-_-_-_-_-_

In the case 2:

Memory__ |_|_|_|_|___|
i =0 |1|2|3|4|5|(6)|
i++ =1 |2|3|4|5|6| - |
it will print 6.

Is This Answer Correct ?    10 Yes 13 No

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

Answer / samir isakoski

If this is a regular c

you cannot put in for loop, non declared integer

it must by declared before the for loop

from 0 to 5

0
1
2
3
4

beacouse it's start from zerro

Is This Answer Correct ?    4 Yes 7 No

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

Answer / shanthi

01234

Is This Answer Correct ?    19 Yes 23 No

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

Answer / sujeesh krishnan

We can't declare a variable in any part of the program
rather than the declaration part.
It doesn't matter whether you use a loop to print or not.
When the statements which are to be executed begins(Here the
looping statement)no declaration is possible in C.
You can do it in C++,C#,java etc.

Is This Answer Correct ?    6 Yes 15 No

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

Answer / kiran123456789

6

Is This Answer Correct ?    4 Yes 21 No

Post New Answer

More C C++ Errors Interview Questions

What is the code for following o/p * * * * * * * * * * * * * * * *

1 Answers  


Why are memory errors hard to debug?

1 Answers  


loop1: { x=i<n?(i++):0; printf("%d",i); exit(x); continue; } Error- misplaced continue. Doubt-1.will the exit(x) be executed for all values of x 2.will this statement go out of the program.

5 Answers   CMC,


wap for bubble sort

3 Answers  


I'm having trouble with coming up with the correct code. Thank You!! The assignment was to write a program using string functions that accepts a price of an item and displays its coded value. The base of the keys: X C O M P U T E R S 0 1 2 3 4 5 6 7 8 9 Sample I/O Dialogue: Enter Price: 489.50 Coded Value: PRS.UX

0 Answers  






printy(a=3,a=2)

3 Answers  


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

0 Answers  


class test { int a; public: test(int b):a(b){} void show(){ cout<<a; } }; void main() { test t1; test t2(5); t1.show(); t2.show(); } }

1 Answers  


Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .

2 Answers  


Display this kind of output on screen. 1 0 1 1 0 1 3. Display this kind of output on screen. 1 1 0 1 0 1 4. Display this kind of output on screen. 1 1 0 1 0 1 5.Display this kind of output on screen. 1 2 3 4 5 6 7 8 9 10

1 Answers  


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

2 Answers   TCS,


what is syntax error?

3 Answers  


Categories