EmbLogic's Blog

Reverse the digits

1        #include <stdio.h>
2        int main()
3        {
4         long int a=0;
5         long int n;
6         printf(“enter a number\n”);
7         scanf(“%ld”, &n);
8         while(n!=0)
9         {
10                 a=a*10;
11                 a=a+(n%10);
12                 n=n/10;
13                 }
14                 printf(“%ld”,a);
15                 return 0;
16                 }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>