Write a program that reads an integer (1-4 digits) and displays the number of its digits and their sum. For example, if the number is 1234, the program should display 4 and 10
寫一個輸入四位整數 輸出數字的位數和位數的總和。例如,數字是1234程式會輸出4和10。
More information about Loops here.
Example input:
1234
Example output:
4 10
Example input 2:
245
3 11
Hidden content!* * * * * *** ***** * int main {int * * ** **** *** * * * * ** * ** ** ** * ** (a != 0){ * ** *** ** * * ** * ** * * += a%10; *** * * * ** * * ** * /= 10;* * *** * *** * * * } ** ** * ** *** **** * * 0;}
Hidden content!#include<stdio.h>int main() {* * * ** *** ***** *** * * * a, a2, b1, b2, b3, b4, i, sum;