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

13/16

Page

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

Comment on the following statement.
n = 1;
printf("%d, %dn", 3*n, n++);

Select an option to see the answer and solution.

Which of the following format identifier can never be used for the variable var?
#include <stdio.h>
int main()
{
    char *var = "The quick brown fox jumps over the lazy dog";
}

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

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#include <string.h>
int main()
{
    char *str = "x";
    char c = 'x';
    char ary[1];
    ary[0] = c;
    printf("%d %d", strlen(str), strlen(ary));
    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 = 2, y = 2;
    x /= x / y;
    printf("%d\n", x);
    return 0;
}

Select an option to see the answer and solution.

Which of the following operators has an associativity from Right to Left?

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 = 3, i = 0;
    do {
        x = x++;
        i++;
    } while (i != 3);
    printf("%d\n", x);
}

Select an option to see the answer and solution.

Which of the following declaration is not supported by 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 a = 5, b = -7, c = 0, d;
    d = ++a && ++b || ++c;
    printf("\n%d%d%d%d", 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>
void foo(const int *);
int main()
{
    const int i = 10;
    printf("%d ", i);
    foo(&i);
    printf("%d", i);

}
void foo(const int *i)
{
    *i = 20;
}

Select an option to see the answer and solution.

Which of the following is the correct order of evaluation for the given expression?
a = w % x / y * 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()
{
    char c;
    int i = 0;
    FILE *file;
    file = fopen("test.txt", "w+");
    fprintf(file, "%c", 'a');
    fprintf(file, "%c", -1);
    fprintf(file, "%c", 'b');
    fclose(file);
    file = fopen("test.txt", "r");
    while ((c = fgetc(file)) !=  -1)
        printf("%c", c);
    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()
{
    printf("Ram\rShyam\n");
    return 0;
}

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 = 3 % 0 * 1 - 4 / 2;
    printf("%lf", b);
}

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

Select an option to see the answer and solution.

What will be the value of the following C expression?
(x = foo()) != 1 considering foo() returns 2

Select an option to see the answer and solution.

In expression i = g() + f(), first function called depends on . . . . . . . .

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++);
    printf("%d%d\n", b, h);
}

Select an option to see the answer and solution.

When double is converted to float, then the value is?

Select an option to see the answer and solution.

Which of the following keywords is used to define an alternate name for an already existing data type?

Select an option to see the answer and solution.