Vidyalelo
C Programming · all questions

C Fundamentals
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

303

Questions

9/16

Page

Pick an option on a question to see the right answer and solution.

What is the type of the following assignment expression if x is of type float and y is of type int?
y = x + y;

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
    int main()
    {
        printf("Hello World! %d \n", x);
        return 0;
    }

Select an option to see the answer and solution.

What will be the final value of c in the following C statement? (Initial value: c = 2)
c <<= 1;

Select an option to see the answer and solution.

Consider this statement: typedef enum good {a, b, c} hello; Which of the following statements is incorrect about hello?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int ThisIsVariableName = 12;
    int ThisIsVariablename = 14;
    printf("%d", ThisIsVariablename);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
int main()
{
    typedef union a
    {
        int i;
        char ch[2];
    }hello;
    hello u;
    u.ch[0] = 3;
    u.ch[1] = 2;
    printf("%d, %d", u.ch[0], u.ch[1]);
    return 0;
}

Select an option to see the answer and solution.

Which of the following operator has the highest precedence in the following?

Select an option to see the answer and solution.

Which function in the following expression will be called first?
a = func3(6) - func2(4, 5) / func1(1, 2, 3);

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int x = 1;
    short int i = 2;
    float f = 3;
    if (sizeof((x == 2) ? f : i) == sizeof(float))
        printf("float\n");
    else if (sizeof((x == 2) ? f : i) == sizeof(short int))
        printf("short int\n");
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int h = 8;
    int b = h++ + h++ + h++;
    printf("%d\n", h);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    enum {ORANGE = 5, MANGO, BANANA = 4, PEACH};
    printf("PEACH = %d\n", PEACH);
}

Select an option to see the answer and solution.

Which of the following is possible with any 2 operators in C?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    double b = 5 % 3 & 4 + 5 * 6;
    printf("%lf", b);
}

Select an option to see the answer and solution.

What will be the output of the following C code? (Initial values: x= 7, y = 8)
#include <stdio.h>
void main()
{
    float x;
    int y;
    printf("enter two numbers \n");
    scanf("%f %f", &x, &y);
    printf("%f, %d", x, y);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int x = 4, y, z;
    y = --x;
    z = x--;
    printf("%d%d%d", x, y, z);
}

Select an option to see the answer and solution.

Which of the following is not a valid variable name declaration?

Select an option to see the answer and solution.

Comment on the behaviour of the following C code?
#include <stdio.h>
int main()
{
    int i = 2;
    i = i++ + i;
    printf("%d\n", i);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
enum colour
{
    blue, red, yellow
};
main()
{
    enum colour c;
    c=yellow;
    printf("%d",c);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int k = 8;
    int x = 0 == 1 && k++;
    printf("%d%d\n", x, k);
}

Select an option to see the answer and solution.

Which of the following is not a pointer declaration?

Select an option to see the answer and solution.