Program to input three number and print their Reverse.
In this program we input three numbers and print their Reverse. First we find 1st digit by (n/100), 2nd digit by(n/10)%10 and 3rd digit by (n%10). Then finally we add a program logic.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,d1,d2,d3,r=0;
clrscr();
printf("Enter three digit number=");
scanf("%d",&n);
d1=(n/100);
d2=(n/10)%10;
d3=n%10;
r=(d3*100)+(d2*10)+d1;
printf("\nReverse of number=%d",r);
getch();
}
OUTPUT
#include<stdio.h>
#include<conio.h>
void main()
{
int n,d1,d2,d3,r=0;
clrscr();
printf("Enter three digit number=");
scanf("%d",&n);
d1=(n/100);
d2=(n/10)%10;
d3=n%10;
r=(d3*100)+(d2*10)+d1;
printf("\nReverse of number=%d",r);
getch();
}
OUTPUT

Comments
Post a Comment