[C] [C] Error expected ';' before 'printf'

Asked 2 years ago, Updated 2 years ago, 50 views

#include<stdio.h>

int main()
{
    int A;
    int B;
    scanf("%d%d",&A,&B);
    if (A>B)
        printf(">");
    else if(A=B)
        printf("==");
    else (A<B)
        printf("<");

}

I don't know why it doesn't work. 136D:\System\Desktop\Unnamed 1.cpp [Error] expected ';' before 'printf' keeps popping up, but I don't know if it's far away.

c c++

2022-09-20 20:49

2 Answers

#include<stdio.h>

int main()
{
    int A;
    int B;
    scanf("%d%d",&A,&B);
    if (A>B)
        printf(">");
    else if(A=B)
        printf("==");
    else (A<B)         // <------- !!!!!
        printf("<");

}

else No condition is required after. Clear (A<B) from else(A<B).


2022-09-20 20:49


2022-09-20 20:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.