Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

C Programming :: Loop Control

Home > C Programming > Loop Control > General Questions

11. What is the output of the following program ?

#include
void main()
{
for (putchar('c');putchar('a');putchar('r'))
putchar('t');
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

12. #include
void main() {
int i,j;
for(i=0;i<=10;i++)
{
j+=5;
assert(i<5);
}}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

asserts are used during debugging to make sure that certain conditions are satisfied. If assertion fails, the program will terminate reporting the same.

Workspace

Tags:

No Tags on this question yet!

13. #include
int i;
void main(){
int t;
for ( t=4;scanf("%d",&i)-t;printf("%d\n",i))
printf("%d--",t--);
}
// If the inputs are 1,2,3 find the o/p

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

14. #include
void main()
{
int i=0;
while(+(+i--)!=0)
i-=i++;
printf("%d",i);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option E

Explanation:

Unary + is the only dummy operator in C.

So it has no effect on the expression and now the while loop is,while(i--!=0)which is false and so breaks out of while loop. The value "-1" is printed due to the post-decrement operator.

Workspace

Tags:

No Tags on this question yet!

15. #include
void main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

16. #include
void main()
{
int i = 3;
for (;i++=0;)
printf("%d",i);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

As we know that increment operators return rvalues and hence it cannot appear on the left hand side of an assignment operation.

Workspace

Tags:

No Tags on this question yet!

17. What is the output of the following 'C' program?

#include
void main()
{
static int i;
while(i<=10)
(i>2)?i++:i--;
printf("%d", i);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Since i is static it is initialized to 0. Inside the while loop the conditional operator evaluates to false, executing i--.
This continues till the integer value rotates to positive value (2147483647).
The while condition becomes false and hence, comes out of the while loop, printing the i value.

Workspace

Tags:

No Tags on this question yet!

18. What will be output of the following "c" code?

#include
void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf("%c %d \n", ch, ch);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

The char type may be signed or unsigned by default. If it is signed then ch++ is executed after ch reaches 127 and rotates back to -128. Thus ch is always smaller than 127.

Workspace

Tags:

No Tags on this question yet!

19. What is the output of the following 'C' program ?

#include
int main()
{
int c = 0;
do
{
int c = 0;
++c ;
printf("\n c = %d ", c );
}
while( ++c <= 3 );
printf("\n c = %d\n", c );
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

20. What is the output of the following 'C' program ?

#include
int main()
{
int i;
for (i = 0; i < 3; ++i)
{
int t = 1;
static int i = 1;
int *ptr = &i;
printf("%d %d\n",t, *ptr);
t = t + 1;
*ptr = *ptr + 1;
}
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!