write a program to reverse a number

 

  1. #include<stdio.h>  
  2.  int main()    
  3. {    
  4. int n, reverse=0, rem;    
  5. printf("Enter a number: ");    
  6.   scanf("%d", &n);    
  7.   while(n!=0)    
  8.   {    
  9.      rem=n%10;    
  10.      reverse=reverse*10+rem;    
  11.      n/=10;    
  12.   }    
  13.   printf("Reversed Number: %d",reverse);    
  14. return 0;  
  15. }   

Comments

Popular posts from this blog

250+ C Programs for Practice

FUNCTION OVERRIDING IN CPP