Everyone a great god, and how to use the do while loop to a sum of the three digits of the number?
CodePudding user response:
To understand the meaning of the two expressions, can write the 10 I % I/10
CodePudding user response:
Position and in turn
CodePudding user response:
Already know is 3 digits, and with what cycle? N/100 is the digits of n (n % 100)/10 is ten digits of n To single digits of n is n % 10 Had taken each together
CodePudding user response:
#include Int main () { char s[10]; Int ans=0; The scanf (" % s ", s); for(int i=0; i<3; + + I) { Ans +=(s [I] - '0'); } Printf (" % d ", ans); return 0; }