Thread: Determine the order part.2

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    73

    Smile Determine the order part.2

    ok, I cant seem to make the last part work. If the order is not ascending or descending it needs to be "No order at all" why is this not working? Please dont give answers just direct me to what I am doing wrong. I have a feeling its in my else if statement. thanks

    Bryan

    Code:
    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    int main()
    
    {
    	
    	float A;
    	float B;
    	float C;
    	float D;
    	float E;
    	
    
    	cout << "Enter 1st Interger then press enter:" << endl;
    	cin >> A;
    	cout << "Enter 2nd Interger then press enter:" << endl;
    	cin >> B;
    	cout << "Enter 3rd Interger then press enter:" << endl;
    	cin >> C;
    	cout << "Enter 4th Interger then press enter:" << endl;
    	cin >> D;
    	cout << "Enter 5th Interger then press enter:" << endl;
    	cin >> E;
    	
    	
    	if (A < E)
    		cout << "Ascending Order" << endl;
    {
    
    	if (A > E)
    		cout << "Descending Order" << endl;
    	}
    	else if
    		cout << "Not in any order at all" << endl;
    	
    return 0;
    }
    Last edited by romeoz; 07-06-2003 at 06:32 PM.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You have braces {} in the wrong place, and the last if statement has no test condition.

    I won't show you an example, as you're so close yourself
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    What is the purpose of including cmath?

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    73
    I am going crazy....maybe just a little more hint..what do u mean by no test condition? do I have to make the else statement like the if statements? I changed my {} around as well.
    Last edited by romeoz; 07-06-2003 at 06:33 PM.

  5. #5
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    naw, like this

    Code:
    if (testcondition)
       statement1;
    else if (testcondition2)
       statement2;
    else
       statement3;
    If testcondition is true, statement1 executes. If it isn't, then if testcondition2 is true, statement2 executes. If neither are true, then statement3 executes.
    Away.

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>what do u mean by no test condition?
    Look at this bit:
    Code:
    else if
    	cout << "Not in any order at all" << endl;
    It says "else if" .... well, if what exactly?


    Basic syntax is
    Code:
    if (condition)
    {
      ...
    }
    else if (another condition)
    {
      ...
    }
    else if (yet another)
    {
      ...
    }
    else
    {
      ... // if all previous tests have failed, we'll end up here.
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User
    Join Date
    Jun 2003
    Posts
    73
    I did it!!! Thanks for all the help Hammer and Blackrat and Munkey...I apprecaite it...here is my final outcome

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    
    {
    	
    	float A;
    	float B;
    	float C;
    	float D;
    	float E;
    	
    
    	cout << "Enter 1st Interger then press enter:" << endl;
    	cin >> A;
    	cout << "Enter 2nd Interger then press enter:" << endl;
    	cin >> B;
    	cout << "Enter 3rd Interger then press enter:" << endl;
    	cin >> C;
    	cout << "Enter 4th Interger then press enter:" << endl;
    	cin >> D;
    	cout << "Enter 5th Interger then press enter:" << endl;
    	cin >> E;
    
    
    	
    	if (A < E)
    	
    		cout << "Ascending Order" << endl;
    	
    	else if  (A > E)
    	
    		cout << "Descending Order" << endl;
    	 
    	
    	
    	else
    	{
    		cout << "Not in any order at all" << endl;
    	}
    return 0;
    }
    Last edited by romeoz; 07-06-2003 at 07:39 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laplace Expansion
    By Leojeen in forum C Programming
    Replies: 7
    Last Post: 10-28-2008, 11:26 PM
  2. Embedded SQL Order By
    By cjohnman in forum C Programming
    Replies: 12
    Last Post: 04-15-2008, 03:45 PM
  3. How do you order your game code?
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 02-05-2006, 06:26 PM
  4. what is the significance of low order and high order bits
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 11-16-2002, 11:46 AM