100% c sum of digits of number & printing number in reverse order
#include <stdio.h>
void main()
{
int rem,numb,total=0,rev_total=0;
printf("\n enter a non-negative integer:");
scanf("%d",&numb);
while(numb)
{
rem=numb%10;
total=total+rem;
numb=numb/10;
rev_total=rev_total*10+rem;
}
printf("\n sum of digits of given number =%d",total);
printf("\n reverse of given number =%d",rev_total);
}
ఔట్పుట్ తెర మీద ఇలా..
enter a non-negative integer:246
sum of digits of given number =12
reverse of given number =642
sum of digits of given number =12
reverse of given number =642
enter a non-negative integer:0
sum of digits of given number =0
reverse of given number =0
sum of digits of given number =0
reverse of given number =0
enter a non-negative integer:246
sum of digits of given number =12
reverse of given number =642
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.