
ЗРОБІТЬ ХОЧА Б ОДНЕ!!!C++Builder Обчисліть добуток всіх цілих <>0 чисел з інтервалу
[-6;5].Ввести з клавіатури n будь-яких чисел. Знайти середнє арифметичне однозначних

Ответы на вопрос

#include <iostream>
using namespace std;
int main()
{
int mult = 1;
for(int i = -6; i <= 5; i++)
if(i != 0)
mult *= i;
cout << mult;
return 0;
}
////////////////////////
#include <iostream>
using namespace std;
int main()
{
float num;
int counter = 0;
float sum = 0;
while(cin >> num)
{
sum += num;
counter++;
}
cout << sum / counter;
return 0;
}



To calculate the product of all non-zero integers within the interval [-6;5] and find the arithmetic mean of single-digit numbers, you can follow these steps:
1. Initialize two variables: `product` and `count`. Set `product` to 1 and `count` to 0. 2. Prompt the user to enter `n` numbers from the keyboard. 3. For each number entered, check if it is within the interval [-6;5]. - If the number is within the interval and is non-zero, multiply it with the current value of `product`. - If the number is a single-digit number, add it to the current value of `count`. 4. After processing all the numbers, calculate the arithmetic mean of single-digit numbers by dividing the value of `count` by the total count of single-digit numbers. 5. Display the product of non-zero numbers and the arithmetic mean of single-digit numbers.
Here's an example implementation in C++:
```cpp
#include
int main() { int product = 1; int count = 0; int n;
std::cout << "Enter the number of values: "; std::cin >> n;
for (int i = 0; i < n; i++) { int num; std::cout << "Enter a number: "; std::cin >> num;
if (num >= -6 && num <= 5) { if (num != 0) { product *= num; } if (num >= -9 && num <= 9) { count++; } } }
std::cout << "Product of non-zero numbers: " << product << std::endl;
std::cout << "Arithmetic mean of single-digit numbers: " << static_cast
return 0; } ```
Please note that this code assumes the user will enter `n` numbers, and it checks if each number is within the interval [-6;5] and if it is non-zero. It also counts the single-digit numbers and calculates their arithmetic mean. Finally, it displays the product of non-zero numbers and the arithmetic mean of single-digit numbers.
Let me know if you have any further questions!


Похожие вопросы
Топ вопросов за вчера в категории Информатика









Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili