|
-
September 9th, 2009, 04:37 PM
#1
Begining Programmer stuck!!!
I am stuck there is a problem in my code but I do not see where it is.
The user is suppose to enter three numbers and then they are to be displayed in numerical order.
This should be simple but I screwed it up. This is homework so I am looking for help, not someone to do my work.
Code:
#include <iostream>
using namespace std;
int main()
{
double num1, num2, num3, first, second, third; // variable declaration
num1 = num2 = num3 = first = second = third = 0;
cout << "Please Enter Three Numbers \n";
cin >> num1 >> num2 >> num3;
first = num1;
if (num2 <= first)
first = num2;
third = num1;
if (num3 <= first)
first = num3;
if (num1 >= first)
if (num1 <= third)
second = num1;
if (num2 >= first)
if (num2 <= third)
second = num2;
first = num3;
third = num1;
if (num3 >= first)
if (num3 <= third)
second = num3;
cout << first << ", " << second << ", " << third << ".";
return 0;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|