Free Programming Basics MCQs with Answers
183 Programming Basics MCQs from Computer Science and IT, each with the correct answer and a written explanation of why it is correct. Free and unlimited, with no account needed.
Programming basics covers algorithms, flowcharts, pseudocode, variables, constants, data types, operators, input and output, conditional statements and loops. It also introduces functions, arrays, strings, debugging and common programming errors, with attention to the difference between syntax errors, runtime errors and logical errors in a program.
Last updated
183 questions · page 8 of 10
- A. 2
- B. 3
- C. 4
- D. 5
Explanation: The correct answer is (a), 2.In C language, there are two main types of comments:Single-line comments: These comments start with "//" and…
Correct answer: 2- A. 2
- B. 2.5
- C. 3
- D. None of these
Explanation: The correct answer is (c) 3.In C programming, when you multiply an integer by a number ending in zero (like 05), the trailing zero is…
Correct answer: 3- A. ROM
- B. RAM
- C. Cache
- D. Register
Explanation: These are small, very fast memory locations within the CPU that hold operands (data) and results used in calculations or instructions.
Correct answer: Register- A. Zero
- B. Garbage
- C. 1
- D. Nothing
Explanation: In C programming, when a variable is declared but not explicitly assigned a value (initialized), its behavior is generally undefined.
Correct answer: Zero- A. Letter
- B. Under score (_)
- C. Digit (0-9)
- D. Both (a) and (b)
Explanation: The correct answer is: (d) Both (a) and (b). In C programming, the first character of a variable name can be either a letter (uppercase or…
Correct answer: Both (a) and (b)- A. 2
- B. 1
- C. 4
- D. 8
Explanation: In most C programming environments, a character type variable typically occupies 1 byte of memory.
Correct answer: 1- A. 1 byte
- B. 2 bytes
- C. .4 bytes
- D. 8 bytes
Explanation: An unsigned long data type typically occupies 4 bytes in memory. This can vary depending on the specific system architecture, but 4 bytes…
Correct answer: .4 bytes- A. Arithmetic overflow
- B. Arithmetic underflow
- C. Truncation
- D. Round off
Explanation: Arithmetic underflow is the phenomenon you are looking for. It happens when the result of a calculation is very small, smaller than the…
Correct answer: Arithmetic underflow- A. int
- B. new
- C. malloc
- D. calloc
Explanation: This function is a standard library function in C used to dynamically allocate a block of memory with a specified size.
Correct answer: malloc- A. float age = 22.5;
- B. int age = 22.5;
- C. double price = 10.99;
- D. All of the above
Explanation: The correct answer is: (d) All of the above. In conclusion, all three options are acceptable ways to declare floating-point variables in…
Correct answer: All of the above- A. Assignment operator
- B. comparison operator
- C. Ternary operator
Explanation: In programming languages, the equal sign (=) is most commonly used as an assignment operator.
Correct answer: Assignment operator- A. #include
- B. Int
- C. void
- D. return
Explanation: The correct answer is (a) #include. #include is a preprocessor directive in C.
Correct answer: #include- A. // This is a comment
- B. / This is a comment /
- C. 'This is a comment'
- D. ! This is a comment
Explanation: The correct answer is: (a) // This is a comment. In C programming, a single-line comment starts with two forward slash characters (//) and…
Correct answer: // This is a comment- A. 5
- B. 6
- C. 8
- D. 9
Explanation: The correct option is (d), 9.There are nine basic arithmetic operators in most programming languages:Addition (+): Adds two operands…
Correct answer: 9- A. =
- B. !
- C. AND
- D. ||
Explanation: The correct answer is (a) =. = is an assignment operator in C. It is used to assign a value to a variable.
Correct answer: =- A. Assignment operator
- B. Unary operator
- C. Ternary operator
- D. Binary operator
Explanation: The correct answer is: (b) Unary operator. Decrement operator (--) is a unary operator that subtracts 1 from the value of its operand (the…
Correct answer: Unary operator- A. Binary operator
- B. Unary operator
- C. Bitwise operator
Explanation: The logical NOT operator (!) is indeed a binary operator in C. However, this answer choice seems to be a mistake in the image you sent.
Correct answer: Binary operator- A. Assignment Operator
- B. Binary Operator
- C. Unary Operators
- D. Ternary Operator
Explanation: Unary operators only require one operand. They are used to perform operations on a single value.
Correct answer: Unary Operators- A. Preprocessor
- B. Functions
- C. Assignment (not shown in the options list but relevant to readability)
- D. Comments
- E. all of the above
Explanation: (d) Comments and all of the above (e) .In conclusion, all of the above options (comments, functions, and meaningful variable names) can be…
Correct answer: all of the above- A. +
- B. -
- C. %
- D. >
Explanation: > is the greater than operator. This is a relational operator, which is used to compare the values of two operands.
Correct answer: >