//How to print reverse number
#include<stdio.h>
#include<conio.h>
void main()
{
int number,reverse_number,rem;
int i,number_of_digit;
clrscr();
printf("Enter the number:");
scanf("%d",&number);
printf("Enter the number of digits you entered number:");
scanf("%d",&number_of_digit);
reverse_number=0;
for(i=0;i < number_of_digit;i++)
{
rem=number%10;
number=number/10;
reverse_number=reverse_number*10+rem;
}
printf("Reverse number:%d",reverse_number);
getch();
}
Output:
Enter the number:542Enter the number of digits you entered number:3
Reverse number:245
No comments:
Post a Comment