1. Find the sum of digits and reverse of a
number.
Eg:- If the number is 123 then sum
of digits=1+2+3=6 and reverse of the
number = 321.
#include<stdio.h>
#include<conio.h>
void
main()
{
int
n,a,sum=0,r=0;
clrscr();
printf("Enter
any no to get its reverse:");
scanf("%d",&n);
while(n>=1)
{
a=n%10;
r=r*10+a;
sum=sum+a;
n=n/10;
}
printf("Sum
of the number=%d\n", sum);
printf("Reverse
of the number=%d",r);
getch();
}
Output
No comments:
Post a Comment