Previous Post:
C #4-Palindrome Number or not using C Program
Next Post:
C #6-Reversing String Using String Program without using String function.
Source code:
#include<stdio.h>
void main()
{
int n, r, rev=0;
printf("Enter the number to Reverse :");
scanf("%d", &n);
while(n)
{
r=n%10;
rev=(rev*10)+r;
n=n/10;
}
printf("Reversed number : %d", rev);
}
Output:
Enter the number to Reverse: 10
Reversed number : 01
C #4-Palindrome Number or not using C Program
Next Post:
C #6-Reversing String Using String Program without using String function.
Reversing of given Number Using C
Source code:
#include<stdio.h>
void main()
{
int n, r, rev=0;
printf("Enter the number to Reverse :");
scanf("%d", &n);
while(n)
{
r=n%10;
rev=(rev*10)+r;
n=n/10;
}
printf("Reversed number : %d", rev);
}
Output:
Enter the number to Reverse: 10
Reversed number : 01
Thanks and regards,
Tech Bird
Comments