Exp2 (B)
Exp2 (B)
While loop:
#include <stdio.h>
int main() {
int i=1 ;
while (i <= 5) {
printf("%d\n", i);
i++; }
return 0;
}
Output:
1
2
3
4
5
Do-While loop:
#include <stdio.h>
int main() {
int i = 1;
do {
printf("%d\n", i);
i++;
} while (i <= 5);
return 0;
}
Output:
1
2
3
4
5
Output:
Table of 2
1x2=2
2x2=4
3x2=6
4x2=8
5 x 2 = 10
6 x 2 = 12
7 x 2 = 14
8 x 2 = 16
9 x 2 = 18
10 x 2 = 20
Output:
Table of 2 Table of 3
1x2=2 1x3=3
2x2=4 2x3=6
3x2=6 3x3=9
4x2=8 4 x 3 = 12
5 x 2 = 10 5 x 3 = 15
6 x 2 = 12 6 x 3 = 18
7 x 2 = 14 7 x 3 = 21
8 x 2 = 16 8 x 3 = 24
9 x 2 = 18 9 x 3 = 27
10 x 2 = 20 10 x 3 = 30
Output:
Table of 6 Table of 7
1x6=6 1x7=7
2 x 6 = 12 2 x 7 = 14
3 x 6 = 18 3 x 7 = 21
4 x 6 = 24 4 x 7 = 28
5 x 6 = 30 5 x 7 = 35
6 x 6 = 36 6 x 7 = 42
7 x 6 = 42 7 x 7 = 49
8 x 6 = 48 8 x 7 = 56
9 x 6 = 54 9 x 7 = 63
10 x 6 = 60 10 x 7 = 70