conditions and output prob

This is a discussion on conditions and output prob within the C++ Programming forums, part of the General Programming Boards category; below is my what i hve done so far....the problem is when both min.degree and max.degree is true, the output ...

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    18

    conditions and output prob

    below is my what i hve done so far....the problem is when both min.degree and max.degree is true, the output will display the one condition(e.g in minNum<0) and both conditions(e.g (minNum < 0) && (maxNum > 360).

    how can i make it displaying the both conditions only?



    [tag]

    Code:
     else if (minNum < 0)
                  {
                   cout << "\n * Min.degree must be greater than 0" << endl;
                   cout << "\n * Please restart the program" <<endl;       
                  }
                else if (maxNum > 360)
                  {
                   cout << "\n * Max.Number should not be more than 360" << endl;
                   cout << "\n * Please restart the program" <<endl;       
                  }
               
              else if ((minNum < 0) && (maxNum > 360))
                  { 
                   
                   cout << "\n * Min.degree must be greater than 0" << endl;
                   cout << "\n * Max.Number should not be more than 360" << endl;
                   cout << "\n * Please restart the program" <<endl;
                  }
    [/tag]

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Remove the "else" in "else if."
    If you have "else if", it will only continue looking until it has found a true condition and skip the rest.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    18
    but now the problem is it display all the conditions that is true in the 'if'

    i just want the output display one condition when both conditions are true.

    Any other solutions?

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    18
    have sorted it out.....i just put 'else if' in the last conditions.....do u agree with that?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. if and while conditions
    By firehydrant in forum C Programming
    Replies: 12
    Last Post: 03-05-2011, 02:07 AM
  2. Error conditions?
    By FlamingAhura in forum C Programming
    Replies: 2
    Last Post: 11-14-2010, 05:12 PM
  3. cout output prob large file read
    By kryptkat in forum C++ Programming
    Replies: 2
    Last Post: 02-06-2010, 02:05 PM
  4. Multiple conditions for while
    By sfff in forum C Programming
    Replies: 5
    Last Post: 11-08-2009, 10:10 PM
  5. Real quick!!! Output prob.
    By eater in forum C Programming
    Replies: 6
    Last Post: 04-23-2009, 02:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21