1. Direct method -
2. loop -
#include <stdio.h> int main() { int a,o,t,h,th,n; scanf("%d",&a); o=a/1000;a=a%1000; t=a/100;a=a%100; h=a/10;a=a%10; th=a; printf("%d",1000*th+100*h+10*t+o); return 0; }
Output -
465 564
2. loop -
#include <stdio.h>
int main()
{
int r,n,sum=0;
scanf("%d",&n);
while(n>0)
{
r=n%10;
n=n/10;
sum=sum*10+r;
}
printf("%d",sum);
return 0;
}
Output -
1234
4321
0 Comments