1. Write a C program to reverse an Integer number. After print the output, make the sum of all digits.
Sample Input:
Enter Number: 571
Output:
After Reverse: 175
Sum of all Digits: 13
Source:
main()
{
int num, i, sum=0;
scanf("%d", &num);
printf("After Reverse: ");
while(num!= 0)
{
i = num%10;
num /=10;
sum += i;
printf("%d", i);
}
printf("\n\nSum of all Digits: %d", sum);
getch();
return 0;
}
<< Go to Index Page >>
#include
উত্তরমুছুনmain()
{
int num, I, sum=0;
scanf("%d", &num);
printf("After Reverse: ");
while(num!=0)
{
I=num%10;
num/=10;
sum+=I;
printf("%d", I);
}
printf("\n\nSum of all Digits: %d", sum);
getch();
return 0;
}
#include
উত্তরমুছুন#include
main()
{
int a,b=0;
printf("Enter the numbers which you to reverse:\t");
scanf("%d",&a);
while(a!=0)
{
b=b*10;
b=b+a%10;
a=a/10;
}
printf("\nThe Reverse numbers are = %d\n",b);
return 0;
}