Sudeda skaiciu suma c++

PHOTO EMBED

Wed Oct 18 2023 16:00:17 GMT+0000 (Coordinated Universal Time)

Saved by @AdomsNavicki

#include <stdio.h>
// Main body of the program
int main() {
  // Declare the variables
  int number, sum = 0;

  scanf("%d", &number);

  // Loop using a while statement
  // The loop will run till the number is not equal to 0
  while (number != 0) {
    // Sum plus the number divided by 10 to skip a place
    sum += number % 10;
    // Number is divided by 10
    number = number / 10;
  }
  // Print the sum of the number
  printf("%d\n", sum);
  return 0;
}
content_copyCOPY