PlacementPrep
Practice › Technical › CSE/IT › C Programming
Technical · CSE / IT

C Programming MCQs for placement tests

20 technical questions of moderate difficulty, as asked in campus placement and company tests. Each has a short explanation.

Q1CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    int x = 5;
    int y = x++;
    printf("%d %d", y, x);
    return 0;
}
Q2CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    int a = 5, b = 2;
    printf("%d", a / b);
    return 0;
}
Q3CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    printf("%d", 7 % -3);
    return 0;
}
Q4CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
void swap(int x, int y) { int t = x; x = y; y = t; }
int main() {
    int a = 10, b = 20;
    swap(a, b);
    printf("%d %d", a, b);
    return 0;
}
Q5CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
void swap(int *x, int *y) { int t = *x; *x = *y; *y = t; }
int main() {
    int a = 10, b = 20;
    swap(&a, &b);
    printf("%d %d", a, b);
    return 0;
}
Q6CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    int arr[] = {10, 20, 30, 40};
    int *p = arr;
    printf("%d", *(p + 2));
    return 0;
}
Q7CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
#include <string.h>
int main() {
    char s[] = "Hello";
    printf("%zu", strlen(s));
    return 0;
}
Q8CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    char s[] = "Hello";
    printf("%zu", sizeof(s));
    return 0;
}
Q9CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    for (int i = 0; i < 5; i++) {
        if (i == 3) break;
        printf("%d ", i);
    }
    return 0;
}
Q10CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    for (int i = 0; i <= 5; i++) {
        if (i % 2 == 0) continue;
        printf("%d ", i);
    }
    return 0;
}
Q11CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    int n = 2;
    switch (n) {
        case 1: printf("One"); break;
        case 2: printf("Two"); break;
        case 3: printf("Three"); break;
    }
    return 0;
}
Q12CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    int n = 2;
    switch (n) {
        case 1: printf("One");
        case 2: printf("Two");
        case 3: printf("Three");
    }
    return 0;
}
Q13CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int f(int n) { return n <= 1 ? 1 : n * f(n - 1); }
int main() {
    printf("%d", f(5));
    return 0;
}
Q14CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
void count() { static int c = 0; c++; printf("%d ", c); }
int main() {
    count(); count(); count();
    return 0;
}
Q15CSE/IT · C ProgrammingModerate

Which function is used to allocate memory dynamically and initialise it to zero in C?

Q16CSE/IT · C ProgrammingModerate

What is the size of a pointer on a typical 64-bit system?

Q17CSE/IT · C ProgrammingModerate

Which storage class makes a global variable visible only within its own file?

Q18CSE/IT · C ProgrammingModerate

What does the following declaration mean? int *p[5];

Q19CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    int x;
    x = (2, 3);
    printf("%d", x);
    return 0;
}
Q20CSE/IT · C ProgrammingModerate

What is the output of this C program?

#include <stdio.h>
int main() {
    int c = 97;
    printf("%c", c);
    return 0;
}

Want guided preparation? Placement Papers Prep courses by Dr. Kiran Derle, with video lessons and full-length mocks.

See placement courses ↗