Ask Question
22 January, 21:08

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

+1
Answers (1)
  1. 22 January, 22:31
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers