64 604
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #47672 in C++ for

Question #47672
Using an array write a program that asks for 10 numbers of type int stores it in an array and traversing each item counting the number of items that are greater than 5. Display the result.
Expert's answer
Code
#include <iostream>
 
using namespace std;
 
int main() {
    int numbers[10];
 
    // Input
    cout << "Enter ten integernumbers: ";
    for (int i = 0; i < 10; i++) {
       cin >> numbers[i];
    }
 
    // Output
    int counter = 0;
    for (int i = 0; i < 10; i++) {
        if (numbers[i] > 5) {
           counter++;
        }
    }
 
    cout << "There is " << counter << " greater than5.";
 
    return 0;
}
 
Result
Enter ten integer numbers: 1 2 3 11 7 8 12 15 6 3
There is 6 greater than 5.

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

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions