/** To Find Reverse Of a Number **/
#include<stdio.h>
//#include<conio.h>
void main()
{
int num,rem,sum=0,rev;
//clrscr();
printf("\n /** To Find Reverse Of a Number **/ \n");
printf("\n Enter a number: ");
scanf("%d",&num);
while(num)
{
rem=num%10; //for getting remainder by dividing with 10
num=num/10; //for getting quotient by dividing with 10
sum=sum*10+rem;
}
rev=sum;
printf("\n The Reversed Number is: %d \n\n",rev);
//getch();
return 0;
}
Output: ( using GNU GCC Compiler with code::blocks IDE, hence no need of clrscr(); and getch(); )
#include<stdio.h>
//#include<conio.h>
void main()
{
int num,rem,sum=0,rev;
//clrscr();
printf("\n /** To Find Reverse Of a Number **/ \n");
printf("\n Enter a number: ");
scanf("%d",&num);
while(num)
{
rem=num%10; //for getting remainder by dividing with 10
num=num/10; //for getting quotient by dividing with 10
sum=sum*10+rem;
}
rev=sum;
printf("\n The Reversed Number is: %d \n\n",rev);
//getch();
return 0;
}
Output: ( using GNU GCC Compiler with code::blocks IDE, hence no need of clrscr(); and getch(); )
For C# Program: C# Program to Print Reverse Of a Given Number
No comments:
Post a Comment