Write a C program that prints a given positive integer in reverse order and also sum of the individual digits involved in the given integer.

Posted by Tushar Bedekar

#include< stdio.h>
#include< conio.h>

int main( )
{
int no, rev=0, rem, sum=0;
clrscr( );
printf("Enter the required integer:");
scanf("%d", &no);
while(no>0)
{
rem = no%10;
rev = (10*rev)+rem;
sum = sum+rem;
no=no/10;
}
printf("\nReverse Number : %d", rev);
printf("\nSum of the individual digits : %d", sum);
getch( );

return 0;
}

0 comments:

Post a Comment

back to top