
Задание по программированию на С++ С использованием оператора if () написать программу, которая
будет выводить на экран: «Введи 3 числа», затем считывать введенные с клавиатуры вещественные числа и выводить на экран «Максимальное из введенных !результат!»

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

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
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!


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









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