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
What is a example of a variable?
What does typedef struct mean?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
When should you use a type cast?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
What is d'n in c?
Explain what is meant by high-order and low-order bytes?
What are the uses of a pointer?
What is difference between scanf and gets?
What is the difference between malloc calloc and realloc in c?
What will be your course of action for a push operation?
Explain the difference between structs and unions in c?
Is there any demerits of using pointer?
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
What is extern variable in c with example?