273 views
0 votes
0 votes
#include<stdio.h>

int main()

{

int num=10;

do

{

while(num++ <10);

}while(num++ <=11);

printf(“%d”,num);

}

1 Answer

0 votes
0 votes
The output of this code should be 14.

The key point in this question is: No matter what the do while loop will execute at least once.

After 1st while loop "while(num++ < 10)", num = 11.

After second while loop, "while(num++ <= 11), num = 12. //True.

Will go to do again, after the first while loop.

num = 13, after second while loop num = 14.

//Even though the condition is false but since ++ operator is used before the condition check, therefore it will //implement post-increment and the value will be incremented to one everytime.

Related questions

0 votes
0 votes
2 answers
1
amit166 asked Jan 3, 2019
585 views
void main() { int i=6; for( i; i; i ) { printf(“%d”,i); } }
0 votes
0 votes
0 answers
2
amit166 asked Dec 28, 2018
280 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
1 answer
3
amit166 asked Nov 20, 2018
178 views
int a=10if(i++<10),if(++i<10).,while(i++<10) what is logic behind
0 votes
0 votes
1 answer
4
amit166 asked Nov 20, 2018
538 views
main() { int x=1,y=0,z=5; int a=x&&y&&z++; printf("%d",z); }