Ask Question
31 August, 19:24

Write an algorithm that receives 500 numbers from the user and prints out the maximum of the numbers.

+5
Answers (1)
  1. 31 August, 19:49
    0
    Algorithm:

    1. Create a variable "maxx" and initialize it with INT_MIN.

    2. Create an array of size 500.

    3. for i=0 to 499.

    3.1 Read value from user and store in array.

    3.2 if input >maxx.

    3.3 maxx=input.

    4. maxx will have the largest of all 500 numbers.

    5. end program.

    Implementation In C++:

    #include

    using namespace std;

    / / main function

    int main ()

    {

    / / variable

    int maxx=INT_MIN;

    / / array of size 500

    int arr[500];

    cout<<"Enter 500 numbers:";

    for (int i=0; i<500; i++)

    {/ / read input number

    cin>>arr[i];

    / / find maximum

    if (arr[i]>maxx)

    maxx=arr[i];

    }

    / / print maximum

    cout<<"Maximum of all:"<
    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write an algorithm that receives 500 numbers from the user and prints out the maximum of the numbers. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers