Вопрос задан 03.09.2020 в 01:39. Предмет Информатика. Спрашивает Тябаев Илья.

Задание по программированию на С++ С использованием оператора if () написать программу, которая

будет выводить на экран: «Введи 3 числа», затем считывать введенные с клавиатуры вещественные числа и выводить на экран «Максимальное из введенных !результат!»
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program in C++ to Find the Maximum of Three Numbers

Here's a program in C++ that uses the `if` statement to find the maximum of three numbers entered by the user:

```cpp #include using namespace std;

int main() { float num1, num2, num3;

cout << "Enter three numbers: "; cin >> num1 >> num2 >> num3;

if (num1 >= num2 && num1 >= num3) { cout << "Maximum of the entered numbers: " << num1 << endl; } else if (num2 >= num1 && num2 >= num3) { cout << "Maximum of the entered numbers: " << num2 << endl; } else { cout << "Maximum of the entered numbers: " << num3 << endl; }

return 0; } ```

This program prompts the user to enter three numbers and then compares them using the `if` statement. It checks if `num1` is greater than or equal to `num2` and `num3`, and if so, it prints `num1` as the maximum. If not, it checks if `num2` is greater than or equal to `num1` and `num3`, and if so, it prints `num2` as the maximum. Otherwise, it prints `num3` as the maximum.

Please note that this program assumes the input numbers are of type `float`. If you want to use integers instead, you can change the variable types from `float` to `int`.

Let me know if you have any further questions!

0 0

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

Последние заданные вопросы в категории Информатика

Задать вопрос