Quick Kit: 38 MCQs

All 38 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 19 questions

Q1. Which of the following is a valid variable name in C?

Beginner
A 2nd_value
B _myVar
C int
D my-var

Answers and explanations are in the Veda app.

Q2. What will be the output of the following code? ```c int x = 5; int y = x++; printf("%d %d", x, y); ```

Beginner
A 5 6
B 6 5
C 5 5
D 6 6

Answers and explanations are in the Veda app.

Q3. Which loop is guaranteed to execute its body at least once?

Beginner
A `for` loop
B `while` loop
C `do-while` loop
D All loops guarantee at least one execution

Answers and explanations are in the Veda app.

Q4. What does the following code print? ```c int arr[] = {10, 20, 30}; int *ptr = arr; printf("%d", *(ptr + 1)); ```

Beginner
A 30
B 10
C 20
D The memory address of the second element

Answers and explanations are in the Veda app.

Q5. Which function is used to read a string including spaces from standard input?

Beginner
A `gets`
B `fgets`
C `puts`
D `scanf`

Answers and explanations are in the Veda app.

Q6. What is the output of the following code? ```c int a = 10, b = 20; if (a = b) { printf("Equal"); } else { printf("Not Equal"); } ```

Beginner
A Compilation error
B Not Equal
C Undefined behavior
D Equal

Answers and explanations are in the Veda app.

Q7. Which header file is required for using `malloc` and `free`?

Beginner
A `<math.h>`
B `<string.h>`
C `<stdio.h>`
D `<stdlib.h>`

Answers and explanations are in the Veda app.

Q8. What is the output of the following recursive function for `n = 5`? ```c int fact(int n) { if (n == 0) return 1; return n * fact(n - 1); } ```

Beginner
A 720
B 15
C 120
D 25

Answers and explanations are in the Veda app.

Q9. Which of the following correctly declares a pointer to an integer?

Beginner
A `int *ptr;`
B `pointer int ptr;`
C `int ptr;`
D `int &ptr;`

Answers and explanations are in the Veda app.

Q10. In C, the `&&` operator returns true if at least one operand is true.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q11. A string in C can be modified after it is created using a character array.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q12. The ___ operator is used to access the members of a structure through a pointer.

Beginner

Answers and explanations are in the Veda app.

Q13. A ___ loop is best suited when the number of iterations is known in advance.

Beginner

Answers and explanations are in the Veda app.

Q14. What is a null pointer and why is it useful?

Beginner

Answers and explanations are in the Veda app.

Q15. What is the purpose of the `break` statement in a `switch` statement?

Beginner

Answers and explanations are in the Veda app.

Q16. What is an array in C and how are its elements accessed?

Beginner

Answers and explanations are in the Veda app.

Q17. What is the output of `printf("%d", sizeof(char));` and why?

Beginner

Answers and explanations are in the Veda app.

Q18. What is a structure in C and how do you access its members?

Beginner

Answers and explanations are in the Veda app.

Q19. What is the difference between `getchar` and `putchar`?

Beginner

Answers and explanations are in the Veda app.

Building up · 12 questions

Q20. Explain the difference between the prefix and postfix increment operators in C.

Intermediate

Answers and explanations are in the Veda app.

Q21. How does a `for` loop differ from a `while` loop in terms of structure and typical use cases?

Intermediate

Answers and explanations are in the Veda app.

Q22. Explain the concept of passing by value in C functions.

Intermediate

Answers and explanations are in the Veda app.

Q23. What is the difference between `fprintf` and `fscanf`?

Intermediate

Answers and explanations are in the Veda app.

Q24. Describe the difference between `calloc` and `malloc`.

Intermediate

Answers and explanations are in the Veda app.

Q25. How do you declare a function that takes an array as a parameter?

Intermediate

Answers and explanations are in the Veda app.

Q26. Explain the concept of recursion and provide a simple example.

Intermediate

Answers and explanations are in the Veda app.

Q27. Consider the following C code snippet: ```c int a = 5, b = 10; int result = a++ + --b; printf("%d %d %d", a, b, result); ``` What is the output?

Intermediate
A 6 10 15
B 6 9 14
C 5 9 14
D 6 9 15

Answers and explanations are in the Veda app.

Q28. Which of the following correctly describes the behavior of the `continue` statement inside a `for` loop?

Intermediate
A It terminates the loop immediately.
B It skips the rest of the current iteration and proceeds to the next iteration, including the increment expression.
C It restarts the loop from the beginning.
D It skips the rest of the current iteration and proceeds to the next iteration without executing the increment expression.

Answers and explanations are in the Veda app.

Q29. What is the output of the following code? ```c #include <stdio.h> void swap(int x, int y) { int temp = x; x = y; y = temp; } int main() { int a = 3, b = 7; swap(a, b); printf("%d %d", a, b); return 0; } ```

Intermediate
A 7 3
B 7 7
C 3 3
D 3 7

Answers and explanations are in the Veda app.

Q30. Given the declaration `int arr[] = {2, 4, 6, 8};` and `int *p = arr;`, which expression correctly accesses the value `6`?

Intermediate
A *(p + 2)
B *(p + 3)
C p[3]
D *(arr + 3)

Answers and explanations are in the Veda app.

Q31. What is the output of the following code? ```c #include <stdio.h> int main() { int x = 0; if (x = 1) { printf("True"); } else { printf("False"); } return 0; } ```

Intermediate
A Undefined behavior
B Compilation error
C False
D True

Answers and explanations are in the Veda app.

Topper level · 7 questions

Q32. Explain the concept of pointer arithmetic with an example.

Advanced

Answers and explanations are in the Veda app.

Q33. What is the purpose of the `const` keyword when used with a pointer?

Advanced

Answers and explanations are in the Veda app.

Q34. Consider the following C code snippet: ```c #include <stdio.h> int main() { int a = 5, b = 10; int result = a++ + --b; printf("%d %d %d", a, b, result); return 0; } ``` What is the output?

Advanced
A 6 9 14
B 5 9 14
C 6 9 15
D 6 9 14

Answers and explanations are in the Veda app.

Q35. Given the declaration `int arr[] = {2, 4, 6, 8};` and `int *p = arr;`, which expression correctly accesses the value `6`?

Advanced
A `*(p + 3)`
B `*(arr + 3)`
C `p[3]`
D `*(p + 2)`

Answers and explanations are in the Veda app.

Q36. What is the output of the following code? ```c #include <stdio.h> void swap(int x, int y) { int temp = x; x = y; y = temp; } int main() { int a = 3, b = 7; swap(a, b); printf("%d %d", a, b); return 0; } ```

Advanced
A 3 7
B 7 7
C 3 3
D 7 3

Answers and explanations are in the Veda app.

Q37. What is the output of the following code? ```c #include <stdio.h> int main() { int x = 0; if (x = 1) { printf("True"); } else { printf("False"); } return 0; } ```

Advanced
A Compilation error
B True
C Undefined behavior
D False

Answers and explanations are in the Veda app.

Q38. Consider the following C code that attempts to read a string including spaces: ```c #include <stdio.h> int main() { char str[50]; printf("Enter a string: "); scanf("%s", str); printf("%s", str); return 0; } ``` If the user enters "Hello World", what will be printed?

Advanced
A World
B Hello
C Nothing (empty string)
D Hello World

Answers and explanations are in the Veda app.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free to start, in more than 40 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Paper Solver

Get Veda free See what students get

Free to start · Android app and web · More than 40 languages