Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language inputs a decimal integer data from the keyboard, calculates and outputs the sum of its digits (ignoring symbols).
C language inputs a decimal integer data from the keyboard, calculates and outputs the sum of its digits (ignoring symbols).
Vc6 debugging passed.

# include & ltstdio.h & gt

void main()

{

int I;

int sum = 0;

Printf ("Enter a number:");

scanf("%d ",& ampI);

If (I<0)

I =-I;

while(I & gt; = 10)

{

sum+= I % 10;

I/= 10;

}

sum+= I;

Printf ("Your total is %d\n", sum);

}