Thread: If statement for identical integer

  1. #1
    Unregistered
    Guest

    If statement for identical integer

    This code won't work for identical integers. The program gets three integers from the user and compares them. But this if statement will not work and always says A and B and identical even if they're not. Help please!


    if(A = B)
    {
    printf("A and B are identical");
    }
    else if(B = C)
    {
    printf("B and C are identical");
    }
    else if(A = C)
    {
    printf("A and C are identical");
    }

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    '=' is assignment

    '==' is comparison...

    so if(A == B)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Access Violation
    By Graham Aker in forum C Programming
    Replies: 100
    Last Post: 01-26-2009, 08:31 PM
  2. Integer Problem
    By dmkanz07 in forum C Programming
    Replies: 2
    Last Post: 03-28-2007, 05:29 PM
  3. newbie programmer - needs help bad.
    By hortonheat in forum C Programming
    Replies: 17
    Last Post: 10-20-2004, 05:31 PM
  4. Logical error in Switch Statement..
    By gardenair in forum C Programming
    Replies: 4
    Last Post: 05-19-2003, 10:15 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM