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

  • Home
  • SEARCH
  • 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 8720519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:03:42+00:00 2026-06-13T07:03:42+00:00

So I got this program to run, but now any numbers that I input

  • 0

So I got this program to run, but now any numbers that I input come out as really large numerals. Do I need to add a header for math computation? Or is there something like with C, a printf function for C++?

#include <iostream>                                                     // Necessary 
using namespace std;
#define mMaxOf2(max, min) ((max) > (min) ? (max) : (min))
#define mMaxOf3(Min, Mid, Max)\
{\
     mMaxOf2(mMaxOf2((Min), (Mid)),(Max))\
}

int main()
{
    double primary;
    double secondary;
    double tertiary;
    long double maximum = mMaxOf3(primary, secondary, tertiary);

    cout << "Please enter three numbers: ";
    cin >> primary >> secondary >> tertiary;
    cout << "The maximum of " << primary << " " << secondary << " " << tertiary;
    cout << " using mMaxOf3 is " << maximum;


    return 0;
}
  • 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-13T07:03:43+00:00Added an answer on June 13, 2026 at 7:03 am

    The problem is that you are computing maximum before you get the user’s input. Rearrange your code like this:

        double primary;
        double secondary;
        double tertiary;
        long double maximum;
    
        cout << "Please enter three numbers: ";
        cin >> primary >> secondary >> tertiary;
    
        maximum = mMaxOf3(primary, secondary, tertiary);
    
        cout << "The maximum of " << primary << " " << secondary << " " << tertiary;
        cout << " using mMaxOf3 is " << maximum;
    

    Always remember that code is executed sequentially, or you may say line-by-line. For C++, any changes to variables affect the behavior of later instructions using those modified variables. In your case, you computed maximum first before you have properly set the values of primary, secondary and tertiary which are needed in mMaxOf3.

    As a note, it is completely OK to have primary, secondary, tertiary and maximum have uninitialized values in the case of your program.

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

Sidebar

Related Questions

I'm a newbie and I know that this C program which I got somewhere
I've got a lot of code that's driving me really crazy right now. I'm
I got this error Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading
While compiling a program in Java I got this big WARNING warning: [unchecked] unchecked
I'm new to C programming and I just came across this program and got
I got a C# program which opens a EventWaitHandle like this to get triggered
Got this line of code here but its not working. private void Button_Click(object sender,
I've got a very simple program written in C#, but the loop never exits
I've got an interactive command line program that we'll call program.exe. While it's running,
So this one is a doozie; I've got a pretty large OpenGL solution, written

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.