user3283315
user3283315

Reputation: 5

Expected expression error. C

I am trying to write a code that will take two intergers, and will list all numbers lower than both of them except for those that are a factor of either if the two numbers inputted. At some point in my code though (see below) i am getting an error saying expected expression. I am a beginner so if you could explain this too me as simply as possible.

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        int firstInterger;
        int secondInterger;
        int i;

        printf("Please enter the first interger: ");
        scanf("%i", &firstInterger);

        printf("Please enter the second interger:");
        scanf("%i", &secondInterger);

        for (i = 0; i < firstInterger && i < secondInterger; i++) {
            if ((firstInterger % i !== 0) && (secondInterger % i !== 0)) { //ERROR HERE!
                printf("%i", i);
            }
        }


    }
    return 0;
}

Upvotes: 0

Views: 197

Answers (1)

Merlevede
Merlevede

Reputation: 8170

You have twice the same error in that line. You should replace !== with != or ==

Upvotes: 3

Related Questions