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--);

Answer Posted / shikhar

The answer given by preshit is absolutely correct...Lets
see how ,we have >>>
for(i=5;i>=0;i--)
Now we can write this all as :

//start of program

STEP 1 : for(i=5;i>=0;)
{
STEP 2 : prinf(i--);
STEP 3 : i--;
}
//end of program

TT : now the loop will start with i=5
when control reaches printf it firstly executes its
internal statement i.e i-- and then prints i-1(i.e 4) and
it Reduces i by 1.i becomes 3
NOW once again STEP 1 :go to TT

OUTPUT :
4
2
0

Is This Answer Correct ?    2 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?

1779


What is a wrapper function in c?

592


What happens if you free a pointer twice?

612


code for find determinent of amatrix

1521


Is that possible to store 32768 in an int data type variable?

694






Here is a good puzzle: how do you write a program which produces its own source code as output?

602


What is the use of header?

628


What is double pointer in c?

593


What is difference between union All statement and Union?

630


write a c program to find the sum of five entered numbers using an array named number

1622


Subtract Two Number Without Using Subtraction Operator

360


What are derived data types in c?

616


What is const keyword in c?

753


What is the difference between c and python?

588


What header files do I need in order to define the standard library functions I use?

543