-
February 19th, 2012, 11:14 AM
#1
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=0; i<length; i++)
cin >> marks[i];
cout << " Enter the key : "<<endl;
cin >>key;
int pos;
pos = seqsearch ( marks , length , key )
if ( pos == -1 ){
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=0; i<length; i++)
if ( list[i] == key)
return i;
return -1;
}
-
February 19th, 2012, 11:30 AM
#2
Re: Syntax Error if statement
Missing ; before if. Looks pretty obvious to me.
Code:
pos = seqsearch ( marks , length , key )
if ( pos == -1 ){
-
February 19th, 2012, 11:41 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|