Code Scrappers


Reverse a number C program


              #include<stdio.h>
              #include<stdlib.h>

              void main()
              {
                  int  n, revno = 0, temp, rem;

                  printf("Enter the number\n");

                  scanf("%ld", &n);

                  temp = n;

                  while (n)
                  {
                      rem = n % 10;

                      revno = revno* 10 + rem;

                      n = n / 10;
                  }
                  printf("Given number = %d \n", temp);

                  printf("Its reverse is = %d \n", revno);
              }
          



Output

     Enter the number

     24

     Given number = 24

     Its reverse is = 42