48.9k views
3 votes
Implement a program that requests four numbers (integer or floating-point) from the user. Your program should compute the average of the first three numbers and compare the average to the fourth number. If they are equal, your program should print 'Equal' on the screen. >>>

1 Answer

7 votes

Answer:

#include<iostream>

int main() {

float num_1, num_2, num_3, num_4, average;

//Taking input for four numbers

std::cout << "Enter first number(integer or floating-point)";

std::cin >> num_1;

std::cout << "Enter second number(integer or floating-point)";

std::cin >> num_2;

std::cout << "Enter third number(integer or floating-point)";

std::cin >> num_3;

std::cout << "Enter fourth number(integer or floating-point)";

std::cin >> num_4;

average= (num_1+num_2+num_3)/3;

// Comparing average with fourth number

if (average==num_4)

{

std::cout << "Equal";

}

return 0;

}

User Tahjid Ashfaque
by
9.0k points