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 8237117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:22:00+00:00 2026-06-07T19:22:00+00:00

i’ve searched what does it mean by temporary variable but i couldn’t & i

  • 0

i’ve searched what does it mean by temporary variable but i couldn’t & i couldn’t understand. i’ve done the if-else structures without a temporary variable and now i’m trying to do if-else structure and a temporary variable. I couldn’t find the difference.

the question is to

  1. write a program that reads three integers(a,b and c) and prints the largest of values using if else structure and a temporary variable.
  2. if else structures without a temporary variable.

I’ve done the first question.

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int a,b,c;

cout<<"a : ";
cin>>a;
cout<<"b : ";
cin>>b;
cout<<"c : ";
cin>>c;

if(a>b && a>c)
{
    cout<<"largest : "<<a;
}else{
    if(b>a && b>c)
    {
        cout<<"largest : "<<b;
    }else{
        if(c>a && c>b)
        {
            cout<<"largest : "<<a;
        }else{
            cout<<"error!";
        }
    }
}


getch();
return 0;
}

but for the second question is it like this?

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int a,b,c;
int max;

cout<<"a : ";
cin>>a;
cout<<"b : ";
cin>>b;
cout<<"c : ";
cin>>c;


if(a>b && a>c)
{
    max=a;
    cout<<"largest : "<<max;
}else{
    if(b>a && b>c)
    {
        max=b;
        cout<<"largest : "<<max;
    }else{
        if(c>a && c>b)
        {
            max=c;
            cout<<"largest : "<<max;
        }else{
            cout<<"error!";
        }
    }
}


getch();
return 0;
}

i just want to be confirm because i don’t exactly understand what does it mean by temporary variable.
thanks.

  • 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-07T19:22:02+00:00Added an answer on June 7, 2026 at 7:22 pm

    Actually, you’ve done the second question as your first result. The second version (answering the first question) should look more like this:

    int max;
    if (a > b && a > c) max = a;
    else if (b > a && b > c) max = b;
    else max = c;
    cout << max;
    

    The purpose of the “temporary” variable is to avoid repeating all the print statement as your first example has.

    I don’t like this use of the word temporary. Temporary variables have a special meaning in C++ totally related to variables created by the compiler implicitly when you use certain code constructs. “max” is not a temporary variable, in that sense. Your instructor is perhaps being loose in his use of the terminology.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.