PRACTICAL-SET-4
2. Write a program to reverse the digit.
#include<stdio.h>
#include<conio.h>
void main()
{
int num,r,reverse=0;
clrscr();
printf("Enter the number: ");
scanf("%d",&num);
while(num)
{
r=num%10;
reverse=reverse*10+r;
num=num/10;
}
printf("Reverse of a given number is = %d",reverse);
getch();
}
OUTPUT:
Enter the number: 1234
Reverse of a given number is = 4321
2. Write a program to reverse the digit.
#include<stdio.h>
#include<conio.h>
void main()
{
int num,r,reverse=0;
clrscr();
printf("Enter the number: ");
scanf("%d",&num);
while(num)
{
r=num%10;
reverse=reverse*10+r;
num=num/10;
}
printf("Reverse of a given number is = %d",reverse);
getch();
}
OUTPUT:
Enter the number: 1234
Reverse of a given number is = 4321
No comments:
Post a Comment