Answer to Question #331979 in C++ for Zaki

Question #331979

Write a C++ program that asks the user to enter 10 integer values in an array. After entering 10


elements find the maximum number and display it on output screen.

1
Expert's answer
2022-04-21T14:38:11-0400
#include <iostream>
using namespace std;

int main() {
  int i, max, arr[10];

  // Store number entered by the user
  for(i = 0; i < 10; ++i) {
    cout << "Enter Number_" << i + 1 << " : ";
    cin >> arr[i];
    }
    max = arr[0];
  // Loop to find the maximum number
  for(i = 1; i < 10; ++i) {
    if(max < arr[i])
      max = arr[i];
  }

  cout << endl << "Largest element = " << max;

  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