Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

012345
not
0
1
2
3
4
cz their is no printf("\n");
first time i=0 it print 0
scnd time i=1 it print 1
last time i=4 it print 4
but not 5 cz when i=5 :i is not <5
so it will not print 5
10x

Is This Answer Correct ?    4 Yes 5 No

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

Answer / ghiga

0 1 2 3 4 5

Is This Answer Correct ?    2 Yes 3 No

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

Answer / sanjeevi

Guys remember things
1) we cant declare loop variable inside for
2) here i is local to for loop alone..

Is This Answer Correct ?    1 Yes 2 No

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

Answer / chuimaya

It gives an error coz we cannot declare a variable inside the for loop.

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 / krishna krish

0 1 2 3 4

Is This Answer Correct ?    6 Yes 7 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 3 No

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

Answer / ttt

0
1
2
3
4

Is This Answer Correct ?    1 Yes 2 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 10 No

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

Answer / erdem

Ofcourse

01234

(logic for start from 0 to 4 and no blank or tab)

Is This Answer Correct ?    1 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 1 No

Post New Answer

More C C++ Errors Interview Questions

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 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 macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?

2 Answers   TCS,


What are the different types of errors in C and when they occur?

4 Answers  


how to convert decimal to binary in c using while loop without using array

50 Answers   Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,


wap for bubble sort

3 Answers  


Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.

1 Answers  


what are the techniques for reducing the fragility of a memory bug?

1 Answers  


what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }

4 Answers  


UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....

5 Answers  


void main() { int i=7; printf("N= %*d",i,i); }

6 Answers   HCL,


Categories