//reversing a number
#include<stdio.h>
#include<conio.h>
int main()
{
int sum=0,n;
printf("enter a number to reverse : ");
scanf("%d",&n);
while(n)
{
sum=sum*10+n%10;
n=n/10;
}
printf("%d",sum);
_getch();
return 0;
}
i/p : 1234
o/p : 4321
#include<stdio.h>
#include<conio.h>
int main()
{
int sum=0,n;
printf("enter a number to reverse : ");
scanf("%d",&n);
while(n)
{
sum=sum*10+n%10;
n=n/10;
}
printf("%d",sum);
_getch();
return 0;
}
i/p : 1234
o/p : 4321
No comments:
Post a Comment