C program to reverse numbers


0

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;
}

Like it? Share with your friends!

0
mrwixxsid

0 Comments

Choose A Format
Personality quiz
Series of questions that intends to reveal something about the personality
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Poll
Voting to make decisions or determine opinions
Story
Formatted Text with Embeds and Visuals
List
The Classic Internet Listicles
Countdown
The Classic Internet Countdowns
Open List
Submit your own item and vote up for the best submission
Ranked List
Upvote or downvote to decide the best list item
Meme
Upload your own images to make custom memes
Video
Youtube and Vimeo Embeds
Audio
Soundcloud or Mixcloud Embeds
Image
Photo or GIF
Gif
GIF format