0% found this document useful (0 votes)
23 views4 pages

Exp2 (B)

Uploaded by

owaisshaikh8454
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Exp2 (B)

Uploaded by

owaisshaikh8454
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

24CO67 - Qazi Muskaan

Branch - Computer (First Year), Semester - I, Div - C,


C programing Lab, / VSEC102, / 2024-25 (R24)

Exp- 02 - b) Program to demonstrate looping - while, do-while

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

=== Code Execution Successful ===

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

=== Code Execution Successful ===

C Programming (R24) LAB Experiments First Year Engineering


24CO67 - Qazi Muskaan
Branch - Computer (First Year), Semester - I, Div - C,
C programing Lab, / VSEC102, / 2024-25 (R24)

1. C-program to write table of 2 in a column using while loop


#include <stdio.h>
int main() {
int i = 1;
printf("Table of 2\n");
while (i <= 10) {
printf("%d x 2 = %d\n", i, i* 2);
i++;
}
return 0;
}

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

=== Code Execution Successful ===

2. C-program to write table of 2 and 3 in columns using while loop


#include <stdio.h>
int main() {
int i=1;
printf("Table of 2\t Table of 3\n");
while (i <= 10) {
printf("%d x 2 = %d\t %d x 3 = %d\n", i, i * 2, i, i * 3);
i++; }
return 0;
}

C Programming (R24) LAB Experiments First Year Engineering


24CO67 - Qazi Muskaan
Branch - Computer (First Year), Semester - I, Div - C,
C programing Lab, / VSEC102, / 2024-25 (R24)

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

=== Code Execution Successful ===

3. C-program to write the table of 6 and 7 using Do-While loop


#include <stdio.h>
int main() {
int i=1;
printf("Table of 6\t\tTable of 7\n");
do {
printf("%d x 6 = %d\t\t%d x 7 = %d\n", i, i* 6, i, i * 7);
i++;
} while (i <= 10);
return 0;
}

C Programming (R24) LAB Experiments First Year Engineering


24CO67 - Qazi Muskaan
Branch - Computer (First Year), Semester - I, Div - C,
C programing Lab, / VSEC102, / 2024-25 (R24)

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

=== Code Execution Successful ===

C Programming (R24) LAB Experiments First Year Engineering

You might also like