Thursday, April 25, 2013

Riverse an integer number

Write a program in c which will reverse an integer number.After print the output make the sum of all digits. 



#include<stdio.h>
main()
{
int num, reverse, sum=0;
printf("\n\tIT'S A PROGRAM TO REVERSE AN INTEGER NUMBER\n");
printf("\n\nEnter the number for reverse:");
scanf("%d", &num);
printf("\nAfter Reverse the number is: ");
while(num!= 0)
{
  reverse= num%10;
  num /=10;
  sum += reverse;
  printf("%d", reverse);
}
printf("\n\nSum of all Digits: %d", sum);

getch();
return 0;
}

No comments:

Post a Comment