Welcome to my blog this is test

28 June 2012

2. write a C program to print the reverse of a five digit number : -


//Code:
#include
#include
 void main()
  {
   long int a,b,c,d,e,n,p;
   clrscr();
   printf("\n Enter a five digits  no = ");
    scanf("%ld",&n);
       a=(n%10);
       b=(n/10)%10;
       c=(n/100)%10;
       d=(n/1000)%10;
       e=(n/10000)%10;
       p=a*10000+b*1000+c*100+d*10+e;
     printf("\n The reverse no is = %ld",p);
    getch();
 }

/*Output:
Enter a five digits  no = 12345
The reverse no is = 54321

No comments:

Post a Comment