Program to reverse the integer number

#include "stdio.h"
 int main()

int number; //Number which you want to reverse its digits

remainder; //will be used to take the one's place digit of that number

int reverseNumber = 0; //reverseNumber will contain the resulting reversed digits of the number

scanf("%d",&number); //Ask for the input of that number
 //number =1234;



remainder = number%10; //it will contain the ones place digit e.g. for 1234 it is 4

reverseNumber = reverseNumber*10+remainder; //0*10 +4

number = number/10; //1234/10 = 123


printf("Reversed Number is: %d", reverseNumber); //4321


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s