Advertisement
Qellex

3.2 v - 13

Feb 18th, 2021
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "locale.h"
  3.  
  4.  
  5. void main() {
  6.  
  7.     setlocale(LC_ALL, "rus");
  8.  
  9.     int n, count = 0, sum = 0;
  10.  
  11.     printf("Введите число: ");
  12.     scanf_s("%d", &n);
  13.  
  14.     while (n > 0) {
  15.         sum += n % 10;
  16.         count++;
  17.         n = n / 10;
  18.     }
  19.  
  20.     printf("Кол-во цифр %d, сумма цифр %d", count, sum);
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement