0% found this document useful (0 votes)
3 views10 pages

C Programming

The document contains a series of multiple-choice questions related to programming concepts, specifically focusing on operators, control flow, and syntax in a programming language. Each question presents a specific programming scenario or concept, with four answer options provided. The questions cover topics such as increment operators, bitwise operations, logical operators, and control structures like loops and conditionals.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

C Programming

The document contains a series of multiple-choice questions related to programming concepts, specifically focusing on operators, control flow, and syntax in a programming language. Each question presents a specific programming scenario or concept, with four answer options provided. The questions cover topics such as increment operators, bitwise operations, logical operators, and control structures like loops and conditionals.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link] does `x = (a > b) ? a : b;` do?

a) Finds maximum

b) Finds minimum

c) Swaps values

d) Compares

34. What is `i++` vs `++i`?

a) Post-increment vs pre-increment

b) Add 1 vs add 2

c) Same thing

d) Different precedence

35. What does `int x = 5; printf("%d", x++);` print?

a) 5

b) 6

c) 0

d) Undefined

36. What is `int x = 5; printf("%d", ++x);`?

a) 5

b) 6

c) 0

d) Undefined

37. What does comma operator do?

a) Separates arguments

b) Evaluates multiple expressions, returns last

c) Declares multiple variables

d) All of these
38. What is `x = (1, 2, 3);`?

a) x = 1

b) x = 2

c) x = 3

d) Compilation error

39. What is `sizeof` operator's result type?

a) int

b) size_t

c) unsigned long

d) Platform dependent

40. What is `sizeof x` vs `sizeof(int)`?

a) Same if x is int

b) Different syntax

c) Parentheses optional for types

d) All true

41. What is bitwise AND operator?

a) &

b) &&

c) |

d) ||

42. What is `5 & 3`?

a) 7

b) 1

c) 0
d) 5

43. What is bitwise OR operator?

a) &

b) &&

c) |

d) ||

44. What is `5 | 3`?

a) 7

b) 1

c) 0

d) 5

45. What is bitwise XOR operator?

a) ^

b) ~

c) !

d) &

46. What is `5 ^ 3`?

a) 6

b) 1

c) 0

d) 7

47. What is bitwise NOT operator?

a) ^

b) ~
c) !

d) &

48. What is `~0` in 8-bit?

a) 0

b) 255

c) -1

d) 1

49. What is left shift operator?

a) <<

b) >>

c) <

d) >

50. What is `5 << 1`?

a) 10

b) 2

c) 3

d) 6

51. What is right shift operator?

a) <<

b) >>

c) <

d) >

52. What is `5 >> 1`?

a) 2
b) 10

c) 3

d) 0

53. What is logical AND operator?

a) &

b) &&

c) |

d) ||

54. What is `5 && 0`?

a) 5

b) 0

c) 1

d) True

55. What is logical OR operator?

a) &

b) &&

c) |

d) ||

56. What is `5 || 0`?

a) 5

b) 0

c) 1

d) False

57. What is logical NOT operator?


a) ^

b) ~

c) !

d) &

58. What is `15`?

a) True

b) False

c) 1

d) 0

59. What is relational operator for equality?

a) =

b) ==

c) ===

d) !=

60. What is `5 == 5`?

a) 1

b) 0

c) True

d) False

---

### Section 3: Control Flow (35 Questions)

61. What is basic if syntax?

a) if condition {}
b) if (condition) {}

c) if condition then {}

d) if {condition}

62. What happens if no braces after if?

a) Next statement only

b) Error

c) All following statements

d) Nothing

63. What is dangling else problem?

a) Else matches nearest if

b) Else is optional

c) Else syntax error

d) All

64. What is `if-else if-else` chain?

a) Multiple conditions

b) Nested if

c) Switch alternative

d) All

65. What is while loop syntax?

a) while condition {}

b) while (condition) {}

c) while {condition}

d) do condition while

66. When does while loop execute?


a) At least once

b) While condition true

c) Fixed times

d) Never

67. What is do-while loop?

a) Executes at least once

b) Checks condition after

c) Both a and b

d) None

68. What is for loop syntax?

a) for (init; condition; update) {}

b) for init, condition, update {}

c) for {init; condition; update}

d) loop (init; condition; update)

69. What is `for(;;)`?

a) Infinite loop

b) Error

c) Zero iterations

d) One iteration

70. What is `for(int i=0; i<5; i++)`?

a) Loops 5 times

b) Loops 6 times

c) Loops 4 times

d) Error
71. What is `break` in loop?

a) Exits loop

b) Skips iteration

c) Restarts loop

d) None

72. What is `continue` in loop?


a) Exits loop
b) Skips to next iteration
c) Restarts loop
d) None

73. What is switch syntax?


a) switch (expression) { case: }
b) switch expression { case }
c) switch (expression) case:
d) switch {expression case:}

74. What types can switch use?


a) Integers
b) Floats
c) Strings
d) All

75. What is `case`?


a) Label for matching value
b) Condition
c) Variable
d) Function

76. What is `default` in switch?


a) Matches when no case matches
b) Required
c) Always executed
d) Error

77. What happens without `break` in case?


a) Fall through to next case
b) Error
c) Exits switch
d) Returns

78. What is `goto` used for?


a) Jump to label
b) Loop control
c) Error handling
d) All

You might also like