Monday, 5 October 2015

Write a program to reverse the digit.

  
   
#include<stdio.h>
//#include<conio.h>
void main() {
    int num, sum = 0;
    //clrscr();
    printf("enter the value of num");
    scanf("%d", &num);
    while (num > 0) {
        sum = sum * 10 + num % 10;
        num = num / 10;
    }
    printf("reverse = % d", sum);
    //getch();
}
Note: Remove the comment line when you are use Turbo C IDE for run your program.

No comments:

Post a Comment