source file name: Revno.C
#include<stdio.h>
int main()
{
long n,d1,d2,d3,d4,d5;
long revno;
//clrscr();
printf("\n enter any 5 digit number: ");
scanf("%ld",&n);// 12345
d1=n%10; // d1= 12345%10=5
n=n/10; // 12345/10=1234
d2=n%10; // 1234%10=4 d2=4
n=n/10; //1234/10=123
d3=n%10; //123%10=3 d3=3
n=n/10; // n=123/10=12
d4=n%10;// 12%10=2 d4=2
n=n/10; // 12/10=1
d5=n%10; // 1%10=1 d5=1
revno=d1*10000+d2*1000+d3*100+d4*10+d5*1; // 54321
printf("\n reverse no=%ld",revno);
//getch();
return 0;
}
output:
enter any 5 digit number: 12345
reverse no= 54321
enter any 5 digit number: 12321
reverse no= 12321
enter any 5 digit number: 76543
reverse no= 34567
2 Comments
Done
ReplyDeleteImportant information
ReplyDeleteSwitch case in C
While loop in C
Structure in C
Read these important topics of c
Post a Comment