Search

C Program to reverse number || C Programs

We can reverse a number in c using loop and arithmetic operators. In this program, we are getting number as input from the user and reversing that number. Let's see a simple c example to reverse a given number.

#include<stdio.h> 
 int main()    
{    
int n, reverse=0, rem;    
printf("Enter a number: ");    
  scanf("%d", &n);    
 while(n!=0)    
  {    
     rem=n%10;    
     reverse=reverse*10+rem;    
     n/=10;    
  }    
  printf("Reversed Number: %d",reverse);    
return 0;  
}   

Output -

Enter a number: 123
Reversed Number: 321
2 views0 comments

Related Posts

See All

Program of Random Number in C || C Programs

Code - #include <stdio.h> #include <conio.h> #include <stdlib.h> void main() { // use rand() function to generate the number printf (" The random number is: %d", rand()); pri

Getchar() function in C || C Programs

Code - #include <stdio.h> #include <conio.h> void main() { char c; printf ("\n Enter a character \n"); c = getchar(); // get a single character printf(" You have passed ")

  • 1024px-Telegram_logo.svg
  • download
  • YouTube