IF statement - to conditions

This is a discussion on IF statement - to conditions within the C Programming forums, part of the General Programming Boards category; Hi everyone, here's my first post on the forum :-) As the topic says, it's about if statement with two ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    4

    IF statement - to conditions

    Hi everyone, here's my first post on the forum :-)

    As the topic says, it's about if statement with two conditions (if possible).


    I have over three numbers, and I want to find the smallest. So far this is what I have got:

    Code:
    if ( number1 > number2 ){
         printf ( "%i is larger", number1 );
    }

    What is the best solution for another condition?

    In pseudocode:

    If number1 > number2 AND number1 > number3
    etc etc.

    Thanks

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Code:
    if ((n1>n2) && (n1>n3))
    beware the nested brackets. && is AND, || is OR, ! is NOT (the logical operators)

    [ps. I have more than 1000 posts now! Can I get a job as moderator?! ]
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    4
    Thanks for solving that issue for me!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. multiple conditions - if statement
    By dibble in forum C Programming
    Replies: 8
    Last Post: 03-28-2009, 12:41 PM
  2. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  3. If statement conditions
    By Brewer in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 04:55 AM
  4. string & if statement
    By Curacao in forum C++ Programming
    Replies: 4
    Last Post: 05-02-2003, 09:56 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 03:49 PM

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