Thread: parse error before else

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    2

    parse error before else

    I'm having problem with my assignment here. It keeps on popping 'parse error before else' no matter how I correct it. Can any1 please help
    Code:
    if(array2[j]==array1[i]);
    {
    
        printf("Exist similar element");
    }
    else if(array1[i]!=array2[j]);
    {
        printf("No similar element exist");
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    25,866
    You have an extra semi-colon on each of these lines:
    Code:
    if(array2[j]==array1[i]);
    Code:
    else if(array1[i]!=array2[j]);
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Parse Error Help
    By frterwil in forum C Programming
    Replies: 4
    Last Post: 02-19-2009, 05:28 PM
  2. Parse error before 'int'
    By thealmightyone in forum C Programming
    Replies: 4
    Last Post: 02-05-2009, 02:13 PM
  3. parse error?
    By Drake in forum Game Programming
    Replies: 2
    Last Post: 11-26-2005, 04:11 PM
  4. parse error
    By sworc66 in forum C Programming
    Replies: 3
    Last Post: 08-31-2003, 09:16 PM
  5. parse error
    By c++.prog.newbie in forum Game Programming
    Replies: 2
    Last Post: 10-31-2001, 08:34 PM