Answer to Question #84008 in Python for nafi

Question #84008
Find the average, maximum, minimum, and sum of three numbers given by the user.
1
Expert's answer
2019-01-08T12:07:11-0500

#include <iostream>


using namespace std;


int main() {


// array for 10 integers

int num[10];


// read 10 integers from the keyboard

int i = 0;

while (i < 10) {

int n;

cout << "Input integer #" << i+1 << " in the range 0-100: ";

cin >> n;

// if the integer is less then 0 or larger than 100

if ( (n < 0) || (n > 100) ) {

// display error message

cout << "Error: Integer must be in the range 0-100" << endl;

} else {

// store integer to array

num[i] = n;

i++;

}

};

// count how many of integers are larger than 50

int counter = 0;

for (int i=0; i<10; i++) {

if (num[i] > 50) counter++;

}


// display result

cout << "Number of integers are larger than 50 is " << counter << endl;

// terminate program

return 0;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS