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

which typw of errors ? & how to solve it ?

0 Answers  


How to create a program that lists the capital country when told what the original country is? (Terribly sorry, I'm a novice programmer and would appreciate any help ;). Cheers, Alexxis

0 Answers  


what is meant for variable not found?

3 Answers  


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  


wap for bubble sort

3 Answers  






#include<stdio.h> void main() { int i=1; printf("%d%d%d",i++,++i,i); }

19 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  


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  


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  


Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .

3 Answers  


what is syntax error?

3 Answers  


WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }

25 Answers   HCL,


Categories