/* to reverse any given integer */
#include<stdio.h>
#include<conio.h>
main()
{
int n,m,x,sum=0;
clrscr();
printf("\ngive the number:");
scanf("%d",&n);
m=n;
while(n>0)
{
x=n%10;
sum=sum*10+x;
n=n/10;}
printf("\ngiven number is =%d",m);
printf("\nreversed number is =%d",sum);
getch();
}
#include<stdio.h>
#include<conio.h>
main()
{
int n,m,x,sum=0;
clrscr();
printf("\ngive the number:");
scanf("%d",&n);
m=n;
while(n>0)
{
x=n%10;
sum=sum*10+x;
n=n/10;}
printf("\ngiven number is =%d",m);
printf("\nreversed number is =%d",sum);
getch();
}
No comments:
Post a Comment