0% found this document useful (0 votes)
10 views2 pages

While Loop

Uploaded by

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

While Loop

Uploaded by

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

#include <stdio.

h>

int main() {
int i = 1;

while (i <= 5) {
printf("%d\n", i);
i++;
}

return 0;
}

#include <stdio.h>

int main() {
int i = 1;

do {
printf("%d\n", i); // Prints the current value of i
i++; // Increment i by 1
} while (i <= 5); // Condition is checked after executing the block

return 0;
}
//WAP to program to calculate and display the sum of numbers from 1 to 10
#include <stdio.h>

void main() {
int i = 1, sum = 0;
while(i <= 10) {
sum = sum + i;
i++;
}
printf("Sum of numbers from 1 to 10 = %d", sum);
}
WAP to display the series 5 9 13 ….up 10th term
#include <stdio.h>

void main() {
int i = 1, n = 5;
do {
printf("%d\t", n);
n = n + 4;
i++;
} while(i <= 5); // Modify the loop condition as needed (i<=5 to print 5
terms)
}
WAP to display multiplication table of 6
#include <stdio.h>

void main() {
int i = 1, p;
do {
p = 6 * i;
printf("6 * %d = %d\n", i, p);
i++;
} while(i <= 10);
}

You might also like