Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 2 MCQs Principles of programming

CAP1008 — C Programming 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 C program structure Easy

    Which function is the mandatory entry point of every C program where execution begins?

  2. Question 2 of 60 C program structure Easy

    Which section of a C program is used to include header files like #include <stdio.h>?

  3. Question 3 of 60 character set Easy

    Which of the following is NOT part of the C character set?

  4. Question 4 of 60 identifiers and keywords Easy

    Which of the following is a valid identifier in C?

  5. Question 5 of 60 identifiers and keywords Easy

    How many keywords are defined in standard (ANSI) C?

  6. Question 6 of 60 constants and variables Easy

    Which keyword is used to declare a constant whose value cannot be changed during program execution?

  7. Question 7 of 60 constants and variables Easy

    What is a variable in C?

  8. Question 8 of 60 data types Easy

    Which data type is used to store a single character in C?

  9. Question 9 of 60 data types Easy

    Which of the following is used to store numbers with a decimal point?

  10. Question 10 of 60 unformatted and formatted i/o functions Easy

    Which format specifier is used to print an integer using printf()?

  11. Question 11 of 60 unformatted and formatted i/o functions Easy

    Which function is used to read a single character from the keyboard?

  12. Question 12 of 60 unformatted and formatted i/o functions Easy

    Which function is used to display a string on the screen and automatically moves the cursor to a new line?

  13. Question 13 of 60 unformatted and formatted i/o functions Easy

    In scanf("%d", &n);, what does the & symbol represent?

  14. Question 14 of 60 expressions Easy

    What is the result of the expression 5 + 3 * 2 in C?

  15. Question 15 of 60 arithmetic operators Easy

    Which arithmetic operator returns the remainder of a division?

  16. Question 16 of 60 unary operator Easy

    What does the ++ operator do in C?

  17. Question 17 of 60 relational operator Easy

    Which operator is used to check whether two values are equal in C?

  18. Question 18 of 60 logical operator Easy

    Which of the following is the logical AND operator in C?

  19. Question 19 of 60 assignment and conditional operator Easy

    What is the value of x after int x = (5 > 3) ? 10 : 20;?

  20. Question 20 of 60 bitwise operators Easy

    Which of the following is the bitwise OR operator in C?

  21. Question 21 of 60 C program structure Medium

    In a standard C program, which section is used to include header files and define macros before the main() function?

  22. Question 22 of 60 character set Medium

    Which of the following is NOT part of the valid C character set?

  23. Question 23 of 60 identifiers and keywords Medium

    Which of the following is a valid C identifier?

  24. Question 24 of 60 identifiers and keywords Medium

    How many keywords are reserved in standard ANSI C (C89/C90)?

  25. Question 25 of 60 constants and variables Medium

    What is the output of the following code?
    c
    const int x = 10;
    x = 20;
    printf("%d", x);

  26. Question 26 of 60 data types Medium

    On a typical 32-bit system, what is the size (in bytes) of a double variable?

  27. Question 27 of 60 data types Medium

    What is the output of the following code?
    c
    char c = 'A';
    printf("%d", c);

  28. Question 28 of 60 unformatted and formatted i/o functions- printf(), scanf(), puts(), gets(), getchar(), putchar() Medium

    Which function reads a full line of text including spaces until a newline is encountered?

  29. Question 29 of 60 unformatted and formatted i/o functions- printf(), scanf(), puts(), gets(), getchar(), putchar() Medium

    What does printf("%d", printf("AB")); output?

  30. Question 30 of 60 unformatted and formatted i/o functions- printf(), scanf(), puts(), gets(), getchar(), putchar() Medium

    In scanf, why is the & operator used before variable names for basic types like int?

  31. Question 31 of 60 expressions Medium

    What is the value of the expression 5 + 3 * 2 - 8 / 4?

  32. Question 32 of 60 arithmetic operators Medium

    What is the output of the following code?
    c
    printf("%d", 17 % 5);

  33. Question 33 of 60 unary operator Medium

    What is the output of the following code?
    c
    int a = 5;
    int b = a++ + ++a;
    printf("%d", b);

  34. Question 34 of 60 relational operator Medium

    What is the value of the expression (10 > 5) > 3 in C?

  35. Question 35 of 60 logical operator Medium

    In the expression a && b, if a evaluates to 0, what happens to b?

  36. Question 36 of 60 assignment and conditional operator Medium

    What is the value of max after this code runs?
    c
    int a = 8, b = 12;
    int max = (a > b) ? a : b;

  37. Question 37 of 60 assignment and conditional operator Medium

    After executing int x = 10; x += x -= 5;, what is the value of x?

  38. Question 38 of 60 bitwise operators Medium

    What is the result of 12 & 10 in C?

  39. Question 39 of 60 bitwise operators Medium

    What is the value of 5 << 2?

  40. Question 40 of 60 type conversion and type modifiers Medium

    What is the output of the following code?
    c
    printf("%d", (int)(7.0 / 2));

  41. Question 41 of 60 bitwise operators Hard

    Assuming 32-bit int, what is the value of the expression ~5 & 0xFF when printed with %d?

  42. Question 42 of 60 arithmetic operators Hard

    In C, what is the result of -7 % 3 and 7 % -3 respectively (C99 and later)?

  43. Question 43 of 60 unary operator Hard

    Given int i = 5;, what value is assigned in int j = i++ + ++i; and what is i afterward? (Common compiler behavior)

  44. Question 44 of 60 type conversion and type modifiers Hard

    What does printf("%d\n", (int)(3.99 + 2.99)); print, and why?

  45. Question 45 of 60 logical operator Hard

    For int a = 0, b = 5; int r = a++ && ++b;, what are the final values of r, a, and b?

  46. Question 46 of 60 unformatted and formatted i/o functions- printf(), scanf(), puts(), gets(), getchar(), putchar() Hard

    Given input 12 34 (with a space), what does this code print?
    c
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d", a + b);

  47. Question 47 of 60 assignment and conditional operator Hard

    What is the value of x after int x = 4; x = (x > 2) ? (x < 8 ? x * 2 : x / 2) : x + 1;?

  48. Question 48 of 60 data types Hard

    On a system with 8-bit char, what does unsigned char c = 300; printf("%d", c); print?

  49. Question 49 of 60 bitwise operators Hard

    What is the output of printf("%d", 1 << 3 | 1 << 1);?

  50. Question 50 of 60 type conversion and type modifiers Hard

    What does the following print on a typical system?
    c
    unsigned int u = 10;
    int i = -1;
    if (i < u) printf("less"); else printf("not less");

  51. Question 51 of 60 identifiers and keywords Hard

    Which of the following is a valid C identifier?

  52. Question 52 of 60 expressions Hard

    What is the value of the expression 5 + 3 * 2 % 4 - 1?

  53. Question 53 of 60 constants and variables Hard

    What is the output of printf("%d", 010 + 0x10);?

  54. Question 54 of 60 unformatted and formatted i/o functions- printf(), scanf(), puts(), gets(), getchar(), putchar() Hard

    What does printf("%d", printf("abc")); output?

  55. Question 55 of 60 relational operator Hard

    What does printf("%d", 3 < 2 < 1); print?

  56. Question 56 of 60 bitwise operators Hard

    Which expression correctly toggles (flips) the 3rd bit (bit index 2, value 4) of an integer n while leaving other bits unchanged?

  57. Question 57 of 60 type conversion and type modifiers Hard

    What is printed by float f = 0.1f; printf("%d", f == 0.1);? (Assume IEEE-754)

  58. Question 58 of 60 unary operator Hard

    Given int a = 10; int b = -a++;, what are the values of b and a afterward?

  59. Question 59 of 60 expressions Hard

    What is the output of int x = 5; printf("%d %d", x != 0, !x);?

  60. Question 60 of 60 data types Hard

    On a system where int is 4 bytes, what does printf("%d", sizeof('A')); most likely print in a C program (not C++)?

That's unit 2

Answer a few questions and your score shows up here.