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 9 of 10

  • A. Different type expression
  • B. Same type expression
  • C. int. float type expression
  • D. Mixed type expression

Explanation: The correct option is (d) Mixed type expression. An expression is a combination of values, variables, and operators that evaluates to a…

Correct answer: Mixed type expression
  • A. Exponentiation
  • B. Multiplication
  • C. Integer remainder
  • D. Division

Explanation: The modulus operator, denoted by %, is used to find the remainder after a division operation.

Correct answer: Integer remainder
  • A. Expressions
  • B. Comments
  • C. Operator procedures
  • D. Equal operator

Explanation: Comments are lines of code that are ignored by the compiler. They are used to provide information about the code for programmers who are…

Correct answer: Comments
  • A. 1
  • B. 3
  • C. 8
  • D. 5

Explanation: The correct option is (b) 3. In most programming languages, the percent (%) operator is the modulo operator, which calculates the…

Correct answer: 3
  • A. Modulus
  • B. Increment
  • C. Decrement
  • D. All of above

Explanation: The increment operator, denoted by ++, is used to increase the value of a variable by 1.

Correct answer: Increment
  • A. Numbers
  • B. Underscore (_)
  • C. Letters
  • D. Period (.)

Explanation: While some languages allow periods within variable names (like Python), it's generally discouraged because periods have a special meaning…

Correct answer: Period (.)
  • A. j = 21
  • B. j = 20
  • C. j = 2
  • D. i = 23

Explanation: The correct option is (c) j = 2.Let's break down the expression to understand how we arrive at the answer:i = 0: This assigns the initial…

Correct answer: j = 2
  • A. Zero
  • B. One
  • C. Less than Zero
  • D. Both (a) and (b)

Explanation: While both 0 and 1 are used in some languages to represent boolean values, a relational expression typically evaluates to just one of…

Correct answer: Both (a) and (b)
  • A. (*)
  • B. //
  • C. \
  • D. :

Explanation: In many programming languages, // is the syntax for a single-line comment.

Correct answer: //
  • A. a123
  • B. My name
  • C. int
  • D. Both (b) and (c)

Explanation: The correct option is (c) int. Variable names follow specific rules depending on the programming language.

Correct answer: int
  • A. Function
  • B. Data types
  • C. Keywords
  • D. Both (b) and (c)

Explanation: Function: Functions are blocks of code that perform a specific task. While functions are essential components of a program, they are not…

Correct answer: Both (b) and (c)
  • A. Addition (+)
  • B. Subtraction (-)
  • C. Multiplication (*)
  • D. Division (/)

Explanation: In C, addition, subtraction, and multiplication are binary operators, meaning they operate on two operands.

Correct answer: Division (/)
  • A. a=77
  • B. b=40
  • C. a=117
  • D. Compile time error

Explanation: int a,b;: This line declares two integer variables a and b.a=77;: This line assigns the value 77 to variable a.b=40;: This line assigns…

Correct answer: a=117
  • A. 6
  • B. 7
  • C. 8
  • D. run time error

Explanation: The correct option is (b) 7.Let's break down the code step by step:a=117: This line assigns the value 117 to the variable a.

Correct answer: 7
  • A. 15
  • B. 16
  • C. 17
  • D. Compile time error

Explanation: The code contains two errors that would lead to a compilation error:Data type mismatch: In C, integer is not a valid data type.

Correct answer: Compile time error
  • A. 10
  • B. 15
  • C. 10 16
  • D. 11 16

Explanation: The correct option is (d) 11 16.Let's break down the code and analyze the errors:int x=10°: The degree symbol (°) is not a valid numeric…

Correct answer: 11 16
  • A. 10
  • B. -5
  • C. -6
  • D. 6

Explanation: The code performs the following steps:Variable Initialization:Declares an integer variable number and assigns it the value 6.Declares…

Correct answer: -6
  • A. (x=25)
  • B. (x=100)
  • C. (x=75)
  • D. Compile time error

Explanation: The correct option is (c) (x=75).Let's break down the code step by step and explain why other options are incorrect:int x, y;: This line…

Correct answer: (x=75)
  • A. 20
  • B. 40
  • C. 60
  • D. 80

Explanation: The code defines three integer variables: x, y, and Z.Variable Initialization:x is assigned the value 20.y is assigned the value…

Correct answer: 60
  • A. a=3
  • B. a=5
  • C. a=15
  • D. a=18

Explanation: Let's break down the code step by step:#include <stdio.h>: This line includes the standard input/output library, which provides functions…

Correct answer: a=15