Example
#include<stdio.h>
#include<conio.h>
void main()
{
int i,rev=0,n,a;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
while(n>0)
{ a=n%10;
rev=(rev*10)+a;
n=n/10;
}
printf("Reverse of given number is:%d",rev);
getch();
}
/*=======================================================================
OUTPUT
Enter the number:1234
Reverse of given number is:4321
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,rev=0,n,a;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
while(n>0)
{ a=n%10;
rev=(rev*10)+a;
n=n/10;
}
printf("Reverse of given number is:%d",rev);
getch();
}
/*=======================================================================
OUTPUT
Enter the number:1234
Reverse of given number is:4321
*/
No comments:
Post a Comment