DO WHILE LOOP

       
  1.   1.TABLE IF ONE:

#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

 2.PRINT DIGITS OF INTEGER VALUE IN REVERSE ORDER: 

#include<stdio.h>
int main()
{
int no,b;
printf("Enter any number\n");
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 
589
Reverse is given below
985

3.CHECK NUMBER IS PALINDROME OR NOT :


#include<stdio.h>
int main()
{
int no,b,rev=0,cpy;
printf("Enter any number\n");
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 
5885
Palindrome 

                           4.FIND SUM OF DIGITS OF INTEGER VALUE: 


#include<stdio.h>
int main()
{
int no,b,sum=0;
printf("Enter any number\n");
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 
785
Total sum of digits=20

                        5.FIND MULTIPLY OF DIGITS OF INTEGER NUMBER: 



#include<stdio.h>
int main()
{
int no,b,m=1;
printf("Enter any number\n");
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 
325
Total multiply of digits=30

                      6.PRINT FIRST AND LAST DIGIT OF INTEGER NUMBER: 


#include<stdio.h>
int main()
{
int no,b,f;
printf("Enter any number\n");
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 
4859
First digit=4 and
Second digit=9

          

Comments

Popular posts from this blog

Java vs C++

STRUCTURE

SWITCH PROGRAMME