Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:57:47+00:00 2026-06-13T23:57:47+00:00

I have another task for my school and it is: Write a program which

  • 0

I have another task for my school and it is:

Write a program which will output the largest from three inputed numbers

So far I have done this:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int* numbers = new int[3];

    for(int i = 0; i < 3; i++) {
        cout << "Input number no. " << (i + 1);
        cin >> numbers[i];
        cout << endl;
    }


    system("PAUSE");
    return EXIT_SUCCESS;
}

Is there a helper function/method in C++ which will find a largest number in my numbers array?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:57:48+00:00Added an answer on June 13, 2026 at 11:57 pm

    There’s an algorithm that finds the maximal element in a container (std::max_element), but that’s inappropriate. Your situation can be solved with constant memory consumption, so you don’t need to store all numbers. At any given point, you just need to remember the current maximum.

    Imagine you had to process one gazillion numbers. Then storing them all would not be desirable.

    Of course, internally the max_element algorithm does the same as I just suggested, but it assumes that you already have the container anyway. If you don’t, then just update the maximum on the fly. The boost.accumulators library has something to do that, but I’m sure you can write this yourself — it should only take one or two lines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a task to transfer text files from one pc to another using
iv'e got an asp button which performs another task besides postback i have done
I have a task which, when completed, is supposed to continue with another task
I have another weird problem which I have not been able to solve in
i have another question on getting my XML serialization neat, which i can't seem
I have my remote service which tries to run an activity from a different
This is another prolog task that I can't solve at this moment. I have
I have two Async tasks (A & B) which upon completion will invoke the
I have a data flow task that extracts data from one database and inserts
I have been given the task to fix an Embedded Operating System which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.