/*=================================================================================
**
** File Name : revDigit.c
** Creation Date : Mon 15 Feb 2016 09:18:11 PM IST
** Last Modified : Mon 15 Feb 2016 09:42:45 PM IST
** Compoler : gcc
** Author : Manoj Kumar Patra, manojpatra.in@gmail.com
** Organization : SCIS, University of Hyderabad, India.
**
**===============================================================================*/
#include<stdio.h>
int main()
{
printf("\n= = = = = = = = = Reverse the Number = = = = = = = = = = =");
int no, rev, rem;
printf("\nEnter the number to be reversed : ");
scanf("%d", &no);
while(no)
{
rem = no%10;
no = no/10;
//printf("%d",rem);
rev = (rev*10)+rem;
}
printf("\nThe reverse number of %d is : %d\n",no, rev);
printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}
Output:
max@ubuntu:~/cprog$ gcc revDigit.c -o revDigit
max@ubuntu:~/cprog$ ./revDigit
= = = = = = = = = Reverse the Number = = = = = = = = = = =
Enter the number to be reversed : 12345
The reverse number of 0 is : 54321
= = = = = = = = = = = = = = = = = = = = = = = = = = = = =
**
** File Name : revDigit.c
** Creation Date : Mon 15 Feb 2016 09:18:11 PM IST
** Last Modified : Mon 15 Feb 2016 09:42:45 PM IST
** Compoler : gcc
** Author : Manoj Kumar Patra, manojpatra.in@gmail.com
** Organization : SCIS, University of Hyderabad, India.
**
**===============================================================================*/
#include<stdio.h>
int main()
{
printf("\n= = = = = = = = = Reverse the Number = = = = = = = = = = =");
int no, rev, rem;
printf("\nEnter the number to be reversed : ");
scanf("%d", &no);
while(no)
{
rem = no%10;
no = no/10;
//printf("%d",rem);
rev = (rev*10)+rem;
}
printf("\nThe reverse number of %d is : %d\n",no, rev);
printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}
Output:
max@ubuntu:~/cprog$ gcc revDigit.c -o revDigit
max@ubuntu:~/cprog$ ./revDigit
= = = = = = = = = Reverse the Number = = = = = = = = = = =
Enter the number to be reversed : 12345
The reverse number of 0 is : 54321
= = = = = = = = = = = = = = = = = = = = = = = = = = = = =
No comments:
Post a Comment