in

C program to reverse numbers

C program to reverse numbers and print them on the screen. For example, if the input is 12345, we will print the output like 54321. In the program, we use the modulus operator (%) to obtain the digits of the number. To invert the number write its digits from right to left (reverse).

C program to find the reverse of user-given numbers

//By - blog.mrwixxsid.com
#include <stdio.h>

int main()
{
  int n, r = 0;

  printf("Enter numbers to reverse\n");
  scanf("%d", &n);

  while (n != 0)
  {
    r = r * 10;
    r = r + n%10;
    n = n/10;
  }

  printf("Reverse of the number = %d\n", r);

  return 0;
}

What do you think?

Written by mrwixxsid

Leave a Reply

GIPHY App Key not set. Please check settings

C Program to Find Sum of series 1²+2²+3²+…+n²

Algorithm to Calculate The Power Of n^x