All Free Computer Science and IT MCQs with Answers
Every Computer Science and IT question in the bank, across all chapters, each with the correct answer and a written explanation. Free and unlimited, with no account needed.
2,221 questions · page 68 of 112
- A. struct
- B. union
- C. enum
- D. typedef
Explanation: struct is the keyword used to define a user-defined data type called a structure in C programming.
Correct answer: struct- A. Every variable must be declared before it is used
- B. C code needs to be compiled before execution
- C. C has a rich set of data types
- D. Type conversions require explicit casting
Explanation: • Strongly typed languages enforce strict type checking. This means that the data type of a variable is associated with it at the time of…
Correct answer: Type conversions require explicit casting- A. RAM
- B. ROM
- C. Hard disk
- D. Cache
Explanation: RAM (Random Access Memory) is a volatile memory, meaning that it loses its data when the computer is turned off or loses power.
Correct answer: RAM- A. void
- B. int
- C. main
- D. function
Explanation: In C programming, the void keyword is used to declare a function that does not return any value.
Correct answer: void- A. This is a double quote: "
- B. This is a double quote: \
- C. This is a double quote:
- D. A compiler error
Explanation: \" is the escape sequence used to include a double quotation mark within a string literal.
Correct answer: This is a double quote: "- A. It prints "Press the alarm!" and then the computer's speaker beeps
- B. It prints "Press the alarm! \a" literally
- C. A compiler error
- D. The behavior depends on the specific terminal or console being used
Explanation: \a: The alert (bell) escape sequence. In some environments, it produces an audible beep.
Correct answer: The behavior depends on the specific terminal or console being used- A. Hello World!
- B. Hexadecimal characters: H e l l o W o r l d !
- C. \x48\x65\x6C\x6C... (and so on)
- D. Compiler error or warning
Explanation: \xHH represents a hexadecimal escape sequence. Here, the codes correspond to the ASCII values of the characters "Hello World!".
Correct answer: Hello World!- A. 1276345
- B. 12763\045
- C. 12[some strange symbol]3
- D. Compiler warning or unpredictable behavior
Explanation: \763: Octal escape sequence representing a character (likely a non-printable one).\0: The null terminator, marking the end of the string.
Correct answer: 12[some strange symbol]3- A. The program will crash
- B. The phrase "and it cannot be changed!" will be deleted
- C. The terminal might produce a beep sound after printing the value of x
- D. No visible effect; the \a will be ignored
Explanation: The behavior of \a (alert/bell) is system-dependent. In many terminals, it produces a beep or a sound alert.
Correct answer: The terminal might produce a beep sound after printing the value of x- A. f = 3.14, i = 3, c = *
- B. f = 3.14, i = 3, c = (some non-printable character)
- C. f = 3.14, i = 3, c = '3'
- D. Compiler warning or error
Explanation: • (int) f: Truncates the decimal part of f, storing 3 in i.• (char) i: Converts the integer 3 into its corresponding ASCII character.
Correct answer: f = 3.14, i = 3, c = (some non-printable character)- A. 32768
- B. -32768
- C. -32767
- D. Undefined behavior
Explanation: • short int has a limited range. On most systems, its maximum value is 32767.• Adding 1 causes an integer overflow, resulting in a…
Correct answer: -32768- A. 2.85
- B. 2.86
- C. 3.00
- D. 2.00
Explanation: Integer division would result in 2. However, since z is a double, the expression is implicitly converted to a floating-point calculation…
Correct answer: 2.86- A. Positive
- B. Negative
- C. Compiler warning
- D. Undefined behavior
Explanation: x + y involves an unsigned and a signed integer. The signed integer is implicitly converted to unsigned.-10 when represented in unsigned…
Correct answer: Positive- A. 2.00
- B. 2.50
- C. 2.75
- D. 3.00
Explanation: (float) x: Explicitly casts the integer x to a float.The division then becomes a floating-point division, resulting in the precise answer…
Correct answer: 2.50- A. a = 4, b = 4, result = -1
- B. a = 4, b = 5, result = 1
- C. a = 4, b = 4, result = 0
- D. a = 5, b = 5, result = 0
Explanation: • --a decrements a to 4 first.• b-- uses the current value of b (5) in the subtraction, and then decrements b to 4.• Hence, 4 - 5 = -1.
Correct answer: a = 4, b = 4, result = 0- A. x = 8, y = 1
- B. x = 8, y = -1
- C. x = 9, y = 0
- D. Undefined behavior
Explanation: Modifying the same variable twice within an expression, particularly when using decrement operators, can lead to undefined behavior due to…
Correct answer: Undefined behavior- A. x = -2, y = 1
- B. x = -1, y = 0
- C. x = -2, y = 2
- D. Undefined behavior
Explanation: Again, attempting to modify x multiple times between sequence points leads to undefined behavior, meaning the compiler could produce…
Correct answer: Undefined behavior- A. x = 0
- B. x = -1
- C. x = -2
- D. Undefined behavior
Explanation: Modifying a variable this many times within a single expression leads to undefined behavior, where different compilers might produce…
Correct answer: Undefined behavior- A. x = 7, y = 42
- B. x = 6, y = 36
- C. x = 7, y = 36
- D. The output is undefined due to the order of evaluation
Explanation: The order in which the increment operators and multiplication are applied is not guaranteed by the C standard.
Correct answer: The output is undefined due to the order of evaluation- A. x = 12, y = 22
- B. x = 12, y = 23
- C. x = 11, y = 21
- D. The output is undefined
Explanation: Modifying a variable twice within the same expression, especially when using increment/decrement operators, leads to undefined behavior…
Correct answer: The output is undefined