Program:-
#include < stdio.h >
main (){
int n,sum = 0 ,rev = 0 ,r ;
printf("\n enter the number :\n");
scanf("%d",&n);
for( ; n > 0 ; n = n /10){
r = n % 10;
rev = rev * 10 + r;
sum = sum + r;
}
printf("\n sum of digits is %d",sum);
printf("\n reverse of number is %d ",rev);
}
Output : -
enter the number :
571
sum of digit is 13
reverse of number is 175
No comments:
Post a Comment