Thread: if/else if question

  1. #1
    Akilla
    Guest

    if/else if question

    What's the difference between using two if statements
    and using 1 if and 1 elseif ???

    www.akilla.tk

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Using two if statements causes both of them to be evaluated, an if..else if statement will result in only one being evaluated. I've seen quite a few problems fixed simply by changing a series of if statements to an if..else if construct. I'm assuming you mean something like this by the way:
    Code:
    if ( so and so )
      // Do something
    if ( so and so )
      // Do something else
    Compared to:
    Code:
    if ( so and so )
      // Do something 
    else if ( so and so )
      // Do something else
    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    basically, "else if" is skipped when the first condition is true. pretty simple.

  4. #4
    Akilla
    Guest

    Cool wow..

    cool.. so that means it's going to be faster...

    COOL PROGRAMS @ www.akilla.tk

  5. #5
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    itsnt about how speed ll it be
    its totally different in programming flow

    try the tutorials in this site..........it ll help u to understand the difference
    Programming is a high logical enjoyable art for both programer and user !!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM