Loop Control Statements II-119
int i,j;
clrscr();
for(i=0;i<10;i++)
for(j=0;j<10;i++)
printf("%d",i*j++);
getch();
}
The output is
(a) 0 1 2…..99 (b) 0 1 2…9…..0 1 2…9
(c) 0 1 4 9 16…. 81 (d) 0 1 2 3… 9
Answers
1. (b) 2. (b) 3. (b) 4. (c) 5. (b) 6. (b) 7. (b) 8. (b) 9. (a) 10. (a)
11. (a) 12. (a) 13. (b) 14. (a) 15. (a) 16. (b) 17. (b) 18. (b) 19. (b) 20. (a)
21. (a) 22. (a) 23. (a) 24. (a) 25. (b) 26. (c) 27. (b) 28. (b) 29. (b) 30. (d)
31. (d) 32. (d) 33. (c) 34. (c)
True or False
1. A loop repeatedly executes a block of statements for certain number of times.
2. The loop for(; ;) is a non-working loop.
3. The for(; ;) loop with no arguments can be executed.
4. The loop for (a=1;a<20;a++) will be executed for 20 times.
5. The while(1) is an infinite loop.
6. The loop cannot be nested.
7. Even if the condition is false the do-while loop executes once.
8. The do-while loop must be terminated by semi-colon.
9. The { } defines the block of the statement.
10. In case { } is not defined after the loop statement, the default scope is one statement.
Answers
1. True 2. False 3. True 4. False 5. True 6. False 7. True 8. True 9. True 10. True
Additional Questions
Find the output/s of the following program/s.
1. Program to print numbers and their squares from 1 to 3 using for loop.
void main()
{
int i;
clrscr();
M06_ITL-ESL4791_02_SE_C06.indd 119 12/22/2012 5:02:22 PM