All do while loop program in c language 2021

All do while loop program in c language 2021
All do while loop program in c language 2021

All do while loop program in c language 2021

Do While Loop: A do-while loop is a control structure that executes a block of code at least once, regardless of whether the block of code evaluates to true or false. 

The loop executes its block of code and then checks to see if it should execute again; if so, it does and continues checking until it decides not to execute again.

A do-while loop in c language is a control structure that executes a block of code at least once, regardless of whether the block of code evaluates to true or false. 

The loop executes its block of code and then checks to see if it should execute again; if so, it does and continues checking until it decides not to execute again.

How to print 1 to 10 table using do while loop?

#include<stdio.h>

int main()

{

int i=1;

do

{

printf("%d\n",i);

i++;

}

while(i<=10);

}

*****OUTPUT*****

1

2

3

4

5

6

7

8

9

10


How to print digit value in reverse order?

#include<stdio.h>

int main()

{

int no,b;

printf("Enter any Number:");

scanf("%d",&no);

printf("Reverse is given below\n");

do

{

b=no%10;

printf("%d",b);

no=no/10;

}

while(no!=0);

}

*****OUTPUT*****

Enter any Number:12345679

The reverse is given below

97654321

How to check number is palindrome or not palindrome?

#include<stdio.h>

int main()

{

int no,b,rev=0,cpy;

printf("Enter any Number:");

scanf("%d",&no);

cpy=no;

do

{

b=no%10;

rev=rev*10+b;

no=no/10;

}

while(no!=0);

if(cpy==rev)

printf("Palindrome");

else

printf("Not Palindrome");

}

*****OUTPUT*****

Enter any Number:8

Palindrome

How to find sum of digit of integer value using do while loop?

#include<stdio.h>

int main()

{

int no,b,sum=0;

printf("Enter any Number:");

scanf("%d",&no);

do

{

b=no%10;

sum=sum+b;

no=no/10;

}

while(no!=0);

printf("Total sum of digits:%d",sum);

}

*****OUTPUT*****

Enter any Number:790

The total sum of digits:16

How to find multiplication of integer value using do while loop?

#include<stdio.h>

int main()

{

int no,b,m=1;

printf("Enter any Number:");

scanf("%d",&no);

do

{

b=no%10;

m=m*b;

no=no/10;

}

while(no!=0);

printf("Total multiply of digits:%d",m);

}

*****OUTPUT*****

Enter any Number:345

Total multiply of digits:60

How to print first value and last value using while loop?

#include<stdio.h>

int main()

{

int no,b,f;

printf("Enter any Number:");

scanf("%d",&no);

f=no%10;

do

{

b=no%10;

no=no/10;

}

while(no!=0);

printf("First digit:%d and last digit:%d",b,f);

}

*****OUTPUT*****

Enter any Number:5463

First digit:5 and last digit:3

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.