Write a C program to reverse a number.

Write a C program to reverse a number.


Code:- 
#include<stdio.h>
#include<conio.h>
void main(){

int num=0,rnum=0,cnum,i=1;
clrscr();
printf("Enter a number");
scanf("%d",&num);
cnum = num;

while(cnum!=0){
cnum /= 10;
i *= 10;
}
i /= 10;

while(num!=0){
rnum += (num%10)*i;
num /= 10;
i /= 10;
}


printf("reversed number is %d",rnum);
getch();
}


Algorithm:-

Flowchart:-  

Post a Comment

Previous Post Next Post