Monday, 13 July 2015

Write C Program to Print Reverse Number of Input Numbers

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

No comments:

Post a Comment