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...


how does the for loop work actually..suppose for the
following program how it ll work plz explain to me
for(i=5;i>=0;i--)
prinf(i--);

Answers were Sorted based on User's Feedback



how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / ratan

All above answers are wrong.
Correct answer is
5
3
1.
This is because the value "i" is decremented twice (once in
the loop and second time in the printf() function).

Is This Answer Correct ?    24 Yes 2 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / manju

The output for the given for loop is
5 3 1.
why because...
first the value of (i=5)>=0,so 5 is printed.After that i
value is decremented because of i-- in the printf() and
again i value is decremented as specified in for loop.
Now the value of i=3.
Again the loop will be continued untill the value of i
becomes 0.

Is This Answer Correct ?    15 Yes 1 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / jinga lala

5
3
1

Is This Answer Correct ?    10 Yes 0 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / aparna

both of the answers are wrong

Is This Answer Correct ?    10 Yes 2 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / suresh reddy

The correct answer is

5
3
1

because

in for loop "i--" statement is there and again in printf
statement "i--" is there.

Is This Answer Correct ?    8 Yes 1 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / rima

It will give compilatiin error "warning: passing argument 1
of âprintfâ makes pointer from integer without a cast",
because the syntax of printf is not right.
And it would have been printf("%d",i--);
Then correct answer is 531.


This is the correct answer rest all are wrong.[:)]

Is This Answer Correct ?    5 Yes 2 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / vishnu

ur printf syntax is wrong so..u'll will get syntax error

Is This Answer Correct ?    3 Yes 1 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / devi dayal jangra

syntax error.... in prinf...but it should be corrected then
the result will be
5
3
1
Note ...
in first run I=5; printf(i--) print I which is 5 and store 4
in i.
in second run i-- means 4-1=3 then printf(i--) print 3 and
store 2 in i.
in third run... i-- measn 2-1=1 then printf(i--) print 1 and
store 0 in i.
then decreament statement i-- store 1=-1 and when compare
-1>=0 become false and goto next statement after that loop.

Is This Answer Correct ?    2 Yes 0 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / binz

Answer is
5
3
1

But you should change your printf statement to printf("%d",
i--);

Is This Answer Correct ?    2 Yes 0 No

how does the for loop work actually..suppose for the following program how it ll work plz explain ..

Answer / mahender

printf prints value by using format spicefiers
bt in this printf(i--);
means
error

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

Program to find largest of three numbers without using comparsion operator?

3 Answers  


Why is c so powerful?

0 Answers  


What is a char c?

0 Answers  


Explain how do you override a defined macro?

0 Answers  


what is the purpose of the following code, and is there any problem with the code? void fn(long* p1, long* p2) { register int x = *p1; register int y = *p2; x ^= y; y ^= x; x ^= y; *p1 = x; *p2 = y; }

1 Answers   Google,


What is a program flowchart and how does it help in writing a program?

0 Answers  


What does int main () mean?

0 Answers  


what is out put of the following code? #include class Base { Base() { cout<<"constructor base"; } ~Base() { cout<<"destructor base"; } } class Derived:public Base { Derived() { cout<<"constructor derived"; } ~Derived() { cout<<"destructor derived"; } } void main() { Base *var=new Derived(); delete var; }

3 Answers   Honeywell,


main() { char x; while(x=0;x<=255;x++) printf("\nAscii value %d Charater %c",x,x); }

2 Answers  


1.what are local and global variables? 2.what is the scope of static variables? 3.what is the difference between static and global variables? 4.what are volatile variables? 5.what is the use of 'auto' keyword? 6.how do we make a global variable accessible across files? Explain the extern keyword? 7.what is a function prototype? 8.what does keyword 'extern' mean in a function declaration?

0 Answers  


write a program for the normal snake games find in most of the mobiles.

0 Answers   Accenture, Wipro,


a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none

0 Answers  


Categories