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!#include<stdio.h>int main(){* * * * ** * ** * ** ** i; * *** * ** *** ****** ***** * sum=0,counter=0; * * * * * * *** * ** ** * * ** * * ** * ** * * * {** * ****** * ** * * ***** * ** * ** * ** **** * * ** * * * ** * * * * * * ** * * ** *** ** * * * * * * * i%10; * ** ** * * * ** ** * * * ** * * * * *** * * * ** ***** * * * * * *** ** * *** * *** * * ** * ** *** * * %d",counter,sum);* ** * * ** * ** * * * *** * ** * 0;}
Hidden content!#include * * **** * int main (void){**** ** * * * ** * * * n, count, sum, t, remainder; * * * * * * * ** * ** * = 0;* **** * * * ** * = 0;** *** * * * * * * ** * *** ** *** *** ** * * * * &n);** * ** * * ** ** * * ** ** * = n;