Ask Question
14 June, 11:22

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

+5
Answers (1)
  1. 14 June, 14:42
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers