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

4/16

Page

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

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

Select an option to see the answer and solution.

What will be the final value of j in the following C code?
#include <stdio.h>
int main()
{
    int i = 10, j = 0;
    if (i || (j = i + 10))
        //do something
        ;
}

Select an option to see the answer and solution.

What will be the output of the following C function?
#include <stdio.h>
enum birds {SPARROW, PEACOCK, PARROT};
enum animals {TIGER = 8, LION, RABBIT, ZEBRA};
int main()
{
    enum birds m = TIGER;
    int k;
    k = m;
    printf("%d\n", k);
    return 0;
}

Select an option to see the answer and solution.

What is the size of an int data type?

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 m = 7;
    int z = k < m ? k++ : m++;
    printf("%d", z);
}

Select an option to see the answer and solution.

Pick the incorrect statement with respect to enums.

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 = 2, y = 0;
    int z;
    z = (y++, y);
    printf("%d\n", z);
    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()
{
    int x = 1, y = 0;
    x &&= y;
    printf("%d\n", x);
}

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 a = 5 * 3 % 6 - 8 + 3;
    printf("%d", a);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    float x = 0.1;
    if (x == 0.1)
        printf("India");
    else
        printf("Advanced C Classes");
}

Select an option to see the answer and solution.

What will be the final value of j in the following C code?
#include <stdio.h>
int main()
{
    int i = 0, j = 0;
    if (i && (j = i + 10))
        //do something
        ;
}

Select an option to see the answer and solution.

Will the following C code compile without any error?
#include <stdio.h>
int main()
{
    int k;
    {
        int k;
        for (k = 0; k < 10; k++);
    }
}

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 = 0, y = 2;
    int z = ~x & y;
    printf("%d\n", z);
}

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 a = 4, n, i, result = 0;
    scanf("%d", &n);
    for (i = 0;i < n; i++)
    result += a;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
enum hello
{
    a,b=99,c,d=-1
};
main()
{
    enum hello m;
    printf("%d\n%d\n%d\n%d\n",a,b,c,d);
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#define MAX 2
enum bird {SPARROW = MAX + 1, PARROT = SPARROW + MAX};
int main()
{
    enum bird b = PARROT;
    printf("%d\n", b);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include<stdio.h>
enum shyam
{
    a=2,b=3.56
};
enum shyam s;
main()
{
    printf("%d%d",a,b);
}

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 a[5] = {1, 2, 3, 4, 5};
    int i;
    for (i = 0; i < 5; i++)
        if ((char)a[i] == '5')
            printf("%d\n", a[i]);
        else
            printf("FAIL\n");
}

Select an option to see the answer and solution.

One of the major difference between typedef and #define is that typedef interpretation is performed by the . . . . . . . . whereas #define interpretation is performed by the . . . . . . . .

Select an option to see the answer and solution.