Computing.Net > Forums > Programming > C language error

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C language error

Reply to Message Icon

Name: xsu
Date: September 24, 2002 at 18:02:49 Pacific
OS:  
CPU/Ram:  
Comment:

What is wrong with my code?
i keep getting the "Invalid operand to binary" on line "var1=var1-1;"
please help me solve this. this is a very simple code...it's to count out the prime numbers...
take a look and tell me what is wrong...thankz

#include #include int main(){int numofout;int var1, var2, var3, var4;int count1=3;int count2=3;printf("\n\t\tEnter the number of prime numbers\n\t\tyou wish to find (number > 3):");scanf("%i", &numofout);while(numofout 3! "); scanf("%i", &numofout);}printf("\n\n\t\t1 is the 1st prime number.\n\t\t2 is the 2nd prime number.\n\t\t3 is the 3rd prime number.\n");do{count1=count1+1; do { count2=count2+1; var1=count2; do { var1=var1-1; var2=count2 % var1; } while(var2!=0



Sponsored Link
Ads by Google

Response Number 1
Name: ronnie
Date: September 26, 2002 at 13:57:17 Pacific
Reply:

Try changing "var1=var1-1;" to "var1-=1;" and see if the error still occurs.

I'm not sure if it's only an error on the way you posted the code to the forum, but your last line lacked a closing parentheses.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C language error

C prototype errors on compile www.computing.net/answers/programming/c-prototype-errors-on-compile/1536.html

help with C++ language www.computing.net/answers/programming/help-with-c-language/17856.html

Classes : Basic - C Language www.computing.net/answers/programming/classes-basic-c-language/11058.html