Pq ta giving this error -> error: expected ?;' before ?)' token

Asked

Viewed 4,019 times

-2

I made an algorithm to determine if a number is prime or not, but when compiling it is giving this error when compiling in Ubuntu’s own terminal.

#include <stdio.h>

int main(){

int n, i, divisivel;

 printf("Digite um numero para saber se eh primo: \n");
 scanf("%i", &n);

for(i = n, i >= 0, i--){

            if (n%i == 0){
            divisivel =divisivel + 1;
        }


}

 if(divisivel <=2){
        printf("o numero %i eh primo!: \n", n);

 }else{

    printf("o numero %i não eh primo \n", n);
}
return (0);
}
  • 2

    No for, instead of comma ,, change by semicolon ;

1 answer

2


In your for use ; instead of a comma. So:

for(i = n; i >= 0; i--){
   if (n%i == 0){
      divisivel =divisivel + 1;
   }
}
  • so dude, I figured it out and I tidied up, this giving floating point over error now, I don’t know why.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.