Introduction To Programming

Why programs ? Programming is nothing but making the computers think the same way a human thinks. Programs are made for obtaining a specific solution which can even be solved by humans which when solved by us may consume time..

Friday, February 19, 2010

Reverse Number

Reverse of 12345 is 54321. should not use string.
#include < stdio.h >
int main()
{
int n,a,b;
printf("ENTER THE Number");
scanf("%d",&n);
b=0;
while(n!=0)
{
a=n%10;
b=(b*10)+a;
n=n/10;
}
printf("REVERSED NUMBER:");
printf("%d",b);
}


Output:


ENTER THE NUMBER:
54321

REVERSED NUMBER:
12345