Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,148 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,074 people online right now. Registration is fast and FREE... Join Now!




help with this program

 
Reply to this topicStart new topic

help with this program, srry for double new topic posting

noob2007
5 Apr, 2007 - 03:42 PM
Post #1

New D.I.C Head
*

Joined: 3 Apr, 2007
Posts: 38


My Contributions
I need help with the below descriptions and i have no idea how to start it

Write a C++ program that reads from keyboard 3 integer numbers, with proper input
prompt, and then display the number that is neither the largest nor the smallest. You
may assume that these 3 numbers are distinct in value, or consider a number not to be
the largest (respectively, smallest) if there is another number which is larger
(respectively, smaller) or equal in value.


its the exercises in a textbook. i jus started using this language lik 4 weeks ago so im still kinda lost on these exercises and im using DEV-C++

This post has been edited by noob2007: 5 Apr, 2007 - 04:33 PM
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Help With This Program
5 Apr, 2007 - 04:38 PM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
Well, the site usually requires that a user provide some source code before we provide source code for assignments, but we can certainly get you started.
CODE

#include<iostream>
using namespace std;

int main(void)
{
   int num1,num2,num3;
   return 0;
}

You can use this base code to prompt the users for input, check the values, and print the middle number.
User is offlineProfile CardPM
+Quote Post

noob2007
RE: Help With This Program
5 Apr, 2007 - 05:22 PM
Post #3

New D.I.C Head
*

Joined: 3 Apr, 2007
Posts: 38


My Contributions


CODE
#include <iostream>
#include <iomanip>
#include <windows.h>
using namespace std;


int main()
{
        HANDLE hConsole;
    hConsole = GetStdHandle (STD_OUTPUT_HANDLE);

// Use the three primary colors for mixing any other color.
// Use FOREGROUND_INTENSITY for brighter colors.
    SetConsoleTextAttribute
    (hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);

            
    int num1, num2, num3, midnum;
    

    cout << "This program will display a range of numbers according to what you have\ninputted\n";
    cout << "\nEnter your first number: ";
    cin >> num1;
    cout << "\nEnter your second number: ";
    cin >> num2;
    cout << "Enter your third number: ";
    cin >> num3;
    

    cout << "\nThe number that is neither the largest nor the smallest is: ";
    
    if (num1 < num2)
    cout << num2;
    
    else if (num2 < num1)
    cout << num1;
    
    else if (num2 < num3)
    cout << num3;
    
    else if (num3 < num2)
    cout << num2;
      
    else if (num3 < num1)
    cout << num1;
    
    else if (num1 < num3)
    cout << num3;    
  
       cout << "\n\n";

    system("pause");
    return 0;
}



how l77t am i ? LOL

im lik noob. ive been learning teh basics. This coding does not seem to work ne suggestions?

This post has been edited by noob2007: 5 Apr, 2007 - 05:28 PM
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Help With This Program
5 Apr, 2007 - 05:35 PM
Post #4

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
You need to test multiple conditions:
CODE

if((num1<num2&&num1>num3)||(num1<num3&&num1>num2))
   cout<<num1;
else if((num2<num1&&num2>num3)||(num2<num3&&num2>num1))
   cout<<num2;
else
   cout<<num3;

As for your level of 133t, I'll let the masses decide. smile.gif
User is offlineProfile CardPM
+Quote Post

noob2007
RE: Help With This Program
5 Apr, 2007 - 05:37 PM
Post #5

New D.I.C Head
*

Joined: 3 Apr, 2007
Posts: 38


My Contributions
QUOTE(Amadeus @ 5 Apr, 2007 - 06:35 PM) *

You need to test multiple conditions:
CODE

if((num1<num2&&num1>num3)||(num1<num3&&num1>num2))
   cout<<num1;
else if((num2<num1&&num2>num3)||(num2<num3&&num2>num1))
   cout<<num2;
else
   cout<<num3;

As for your level of 133t, I'll let the masses decide. smile.gif



WOW nice thanks man it works biggrin.gif

This post has been edited by noob2007: 5 Apr, 2007 - 05:41 PM
User is offlineProfile CardPM
+Quote Post

nice1
RE: Help With This Program
10 Apr, 2007 - 11:16 PM
Post #6

New D.I.C Head
*

Joined: 10 Apr, 2007
Posts: 1


My Contributions
QUOTE(noob2007 @ 5 Apr, 2007 - 04:42 PM) *

I need help with the below descriptions and i have no idea how to start it

Write a C++ program that reads from keyboard 3 integer numbers, with proper input
prompt, and then display the number that is neither the largest nor the smallest. You
may assume that these 3 numbers are distinct in value, or consider a number not to be
the largest (respectively, smallest) if there is another number which is larger
(respectively, smaller) or equal in value.


its the exercises in a textbook. i jus started using this language lik 4 weeks ago so im still kinda lost on these exercises and im using DEV-C++


heheheheh...nice one wink2.gif

looks like PP1 getting harder for ya aye wink2.gif

the assessment aint that hard though... takes time getting used to though tongue.gif
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 10:54PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month