(C syntax) the sum of numbers and syntaxes
Knowledge point:
Usage of the character function strlen ()
ASCLL code and number conversion,-48
Flexible array usage and array name usage.
Char a [100]; int I, s = 0, m; scanf ("% s", & a); m = strlen ();
Content: calculates the sum of all the numbers in the input integer.
Input description:
One integer in one row
Output description:
An integer
Input example:
2147483646
Output example:
45
# Include <stdio. h> # include <string. h> int main () {char a [100]; int I, s = 0, m; scanf ("% s", & a); m = strlen (); for (I = 0; I <m; I ++) {s + = a [I]-48;} printf ("% d \ n", s ); return 0 ;}
Number is A of some language terms () A, syntax category B, syntax Form C, syntax meaning D, lexical category E, syntax means
B. Syntax
Enter an integer in the C language program. For example, the number of digits is 3 and the number of digits is 6.
If you do not use the log function and assume that the number of indata is a non-negative integer, you can:
Int n, s;
N = 0;
S = 0;
While (indata ){
N ++;
S + = indata % 10;
Indata/= 10;
}
The number of digits is in n and in s.