Syntax Error if statement
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Syntax Error if statement

  1. #1
    Join Date
    Jul 2010
    Posts
    75

    Unhappy Syntax Error if statement

    Hi

    i got syntax error in if statement ,, i checked the line i put { after the condition don't know where the mistake are


    1>c:\users\hani\test11\test11\code.cpp(20) : error C2143: syntax error : missing ';' before 'if'

    PHP Code:

    # include <iostream>
    using namespace std;
    int seqsearch (int list[],int length,int key);
    void main () {
        
    int marks [30];
        
    int length;
        
    int key;

        
    cout << " Enter number of students : "<<endl;
        
    cin >> length;

        for ( 
    int i=0i<lengthi++)
            
    cin >> marks[i];

        
    cout << " Enter the key : "<<endl;
        
    cin >>key;

        
    int pos;
        
    pos seqsearch marks length key )
            if ( 
    pos == -){
                
    cout << " the key is not found ";
            }
            else {
                
    cout << " the key at position"<<pos<<endl;
            }
        
    }

    int seqsearch (int list[],int length,int key) {
        for ( 
    int i=0i<lengthi++)
            if ( list[
    i] == key)
                return 
    i;
        return -
    1;


  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,980

    Re: Syntax Error if statement

    Missing ; before if. Looks pretty obvious to me.

    Code:
        pos = seqsearch ( marks , length , key ) 
            if ( pos == -1 ){

  3. #3
    Join Date
    Jul 2010
    Posts
    75

    Re: Syntax Error if statement

    Okay Fixed ,, Thanks Buddy GCDEF

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center