Created
December 26, 2024 10:42
-
-
Save vlaleli/dd8dc625b37a1e7218d4e5b7a1b8e483 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| const int SIZE = 17; | |
| int arr[SIZE]; | |
| std::cout << "Enter 17 two-digit integers: "; | |
| for (int i = 0; i < SIZE; ++i) { | |
| std::cin >> arr[i]; | |
| if (arr[i] < 10 || arr[i] > 99) { | |
| std::cerr << "Error: Number must be two digits." << std::endl; | |
| return 1; | |
| } | |
| } | |
| int totalSum = 0; | |
| for (int i = 0; i < SIZE; ++i) { | |
| int number = arr[i]; | |
| while (number > 0) { | |
| totalSum += number % 10; | |
| number /= 10; | |
| } | |
| } | |
| std::cout << "Sum of array digits: " << totalSum << std::endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment