Напишите программу, которая запрашивает n-количество чисел, затем запрашивает ввод n-натуральных чисел. Программа должна вывести на экран в отдельных строках количество и сумму чётных введенных чисел, оканчивающихся на 4.
#include <iostream> int main() { // Ask the user for the number of numbers to enter std::cout << "Enter the number of numbers: "; int n; std::cin >> n; // Initialize variables to store the sum and count of even numbers ending in 4 int sum = 0; int count = 0; // Read in the numbers for (int i = 1; i <= n; i++) { std::cout << "Enter number " << i << ": "; int num; std::cin >> num; // Check if the number is even and ends in 4 if (num % 2 == 0 && num % 10 == 4) { // Add the number to the sum sum += num; // Increment the count count++; } } // Display the results std::cout << "Number of even numbers ending in 4: " << count << std::endl; std::cout << "Sum of even numbers ending in 4: " << sum << std::endl; return 0; } C #include <iostream> int main() { // Ask the user for the number of numbers to enter std::cout << "Enter the number of numbers: "; int n; std::cin >> n; // Initialize variables to store the sum and count of even numbers ending in 4 int sum = 0; int count = 0; // Read in the numbers for (int i = 1; i <= n; i++) { std::cout << "Enter number " << i << ": "; int num; std::cin >> num; // Check if the number is even and ends in 4 if (num % 2 == 0 && num % 10 == 4) { // Add the number to the sum sum += num; // Increment the count count++; } } // Display the results std::cout << "Number of even numbers ending in 4: " << count << std::endl; std::cout << "Sum of even numbers ending in 4: " << sum << std::endl; return 0; }