Answer to Question #348556 in C++ for Hasnat

Question #348556

Create an array of size 20. Take input from the user and find the highest number from the array.

1
Expert's answer
2022-06-08T17:24:06-0400
#include <iostream>
using namespace std;

int main() {
    const int  N=20;
    int i, max, arr[N];

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

  cout << endl << "The highest number from the array = " << 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