SUM AND REVERSE OF A NUMBER
/*Sum And Reverse Of A Number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,sum=0,rev=0,r;
printf("enter the number");
scanf("%d",&n);
while(n>0)
{
r=n%10;
rev=(rev*10)+r;
sum=sum+r;
n=n/10;
}
printf("sum is %d",sum);
printf("\n reverse is %d",rev);
getch();
}
No comments:
Post a Comment