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

who was the present cheif governor of reserve bank of india

6 Answers   State Bank Of India SBI,


To generate the series 1+3+5+7+... using C program

18 Answers  


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

2 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  


I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00

3 Answers   UCB,


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  


full c programming error question based problem

3 Answers   HCL, TCS,


wap for bubble sort

3 Answers  


Using string functions write a program that will accept the name of the capital as input value and will display the corresponding country. ------------------------ Capitals Countries ------------------------ Capitals Countries Ottawa Canada Moscow Russia Rome Italy I can't not get it to run properly

1 Answers   AMA,


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  


Declaration of Cube Guys please help me.. Is this a right way to declare cube.? If i Compile it. It Says: Cube undeclared what should i do? Please help \thanks in advanced #include<stdio.h> #include<math.h> #include<conio.h> main( ) { float x,y; while(x++<10.0) { printf("Enter Number:"); scanf("%d", &x); y = cube(x); printf("%f %f %f \n", x,pow(x,2),y); cube(x); } { float x; float y; y = x*x*x; } getch(); return (y); }

2 Answers  


#include<>stdio.h> #include<>conio.h> { printf("hello"); void main() getch(); } what the out put of this program and why ......plz clear my answer

10 Answers   Wipro,


Categories