edited by
561 views
0 votes
0 votes
void main()

{

   int i=6;

   for(--i; --i; i--)

   {

        printf(“%d”,i);

   }

}
edited by

2 Answers

1 votes
1 votes
for( A; B; C)
        D;

It executes like: A,B,D,C,B,D,C,B,D...B.

i = 6, initially.

A would make i = 5.

B would make i = 4.

D will print 4.

C will make i = 3.

B will make i = 2.

D will print 2.

C will make i = 1.

D will make i = 0, then it will be checked (because pre decrement).

i = 0, so break out of the loop.

 

4 and 2 are printed.

Related questions

0 votes
0 votes
0 answers
1
amit166 asked Dec 28, 2018
276 views
#include <stdio.h>int cou=0;int cal(int a,int b){ int c; cou++; if(b==3) return(a*a*a); else{ c=cal(a,b/3); return(c*c*c); }}int ma...
0 votes
0 votes
0 answers
2
iarnav asked Jul 30, 2018
379 views
for every j != i in {0,....,n-1} is it like for j=0 to n-1; j !=i ; ++j
0 votes
0 votes
2 answers
3
vijju532 asked Jul 18, 2018
345 views
#include<iostream>using namespace std;int main(){ int a[] = {10,20,30,40,50}; cout<<(*(&a+1)-a); return 0;}how th o/p is 5 ??