Code Box
-------------------------------------------------
/*Program to find reverse of a number by for loop in C*/
#include<stdio.h>
#include<conio.h>
void main()
{
int num,num1,len,rem,newnum;
clrscr();
newnum=0;
printf("\n\tReverse Number maker");
printf("\n-------------------------");
printf("\nEnter a number:");
scanf("%d",&num);
num1=num; //to save actual number
for(len=0;num1>=1;len++)
{
rem=num1%10;
num1=num1/10;
newnum=newnum*10+rem; //Reverse formula
}
printf("\nReverse of number is : %d",newnum);
getch();
}
No comments:
Post a Comment