If Else in C MCQs Exercise I

Ques 1 If Else


What is the output of the following code?
int main()
{
    int i=1;
    if(i=='1')
    {
        printf("i=1");
    }
    else
    {
        printf("i is not equal to '1'");
    }
    return 0;
}

A i='1'
B i is not equal to '1'
C Syntax error
D None of these

Ques 2 If Else


What is the output of the following code ?
int main()
{
    int i;
    if(i)
        printf("SmallCode");
    else
        printf("Hello SC User");
    return 0;
}

A Hello SC User
B Error
C Logical Error
D SmallCode

Ques 3 If Else


What is the output of the following code ?

int main()
{
    int i=10;
    if(i<1)
        printf("SmallCode");
    if
        printf("Hello SC User");
    return 0;
}

A Hello SC User
B Syntax Error
C Logical Error
D SmallCode

Ques 4 If Else


What is the output of the following code ?(DEV C++)

int main()
{
    char i="i";
    if(i)
        printf("SmallCode");
    else
        printf("Hello SC User");
    return 0;
}

A Hello SC User
B Error
C Logical Error
D SmallCode

Ques 5 If Else


What is the output of the following C Code?


#include<stdio.h>
int main()
{
    int year = 2022;
    int year = 2023;
    printf("Year : %d\n", year);
    return 0;
}

A Year : 2022
B Year : 2023
C Compilation Error
D None of these