C Fundamentals MCQs

303 questionsC-ProgramPage 28 of 34

Practice free C Fundamentals multiple-choice questions with instant answer feedback and step-by-step solutions. Click an option to check yourself, reveal the full explanation, and work through all 303 questions — no login required.

Question 244easy
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;
}
Question 245easy
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;
}
Question 246easy
Which of the following operators has an associativity from Right to Left?
Advertisement
Question 247easy
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);
}
Question 248easy
Which of the following declaration is not supported by C?
Question 249easy
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);
}
Advertisement
Question 250easy
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;
}
Question 251easy
Which of the following is the correct order of evaluation for the given expression?
a = w % x / y * z;
Question 252easy
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;
}
C Fundamentals MCQs with Answers & Solutions — C-Program | GrabStudy