Computer Knowledge

Programming Fundamentals

2,381 Questions

Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.

Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references

Programming Fundamentals Questions

Multiple choice
  1. Variable

  2. Constant

  3. Array

  4. Definition

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

An array is a data structure that can store multiple values under a single name. Variables and constants typically hold a single value at a time.

Multiple choice
  1. Constant

  2. String

  3. Character

  4. Boolean

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A constant is a value that does not change during program execution, not a data type. String, Character, and Boolean are standard data types used to categorize data.

Multiple choice
  1. name == input

  2. name = input("Enter your name: ")

  3. name == input("Enter your name: ")

  4. name = int(input("Enter your name: "))

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In Python, the input function is used to capture user input, and the assignment operator (=) stores that value into a variable. Option B correctly uses the function with a prompt string.

Multiple choice
  1. A memory location.

  2. A memory store that you cannot change.

  3. A value.

  4. A memory store that you can change.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

A constant is a named memory location whose value is fixed and cannot be altered once the program is running. Variables, by contrast, are designed to have their values changed.

Multiple choice
  1. A memory location.

  2. A memory store that you cannot change.

  3. A value.

  4. A memory store that you can change.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

A variable is a named memory location used to store data that can be modified or updated during the program's execution. This distinguishes it from a constant.

Multiple choice
  1. To explain the code

  2. To ask the coder how he/she is doing

  3. To make the code work

  4. To avoid a syntax error

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Comments are non-executable lines in code used by programmers to document and explain what the code does for human readers. They do not affect program execution.

Multiple choice
  1. Not consistent or having a fixed pattern; liable to change

  2. Somewhere to store functions

  3. Names used to store one or morevalues e.g. a users ages

  4. A symbol that represents a quantity

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Variables are named containers for storing values that can be changed. Option C correctly describes variables as named storage for values like age.

Multiple choice
  1. Loops

  2. Selection

  3. Iteration

  4. Procudure

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Selection statements (also known as conditional statements) allow a program to choose different paths of execution based on whether a condition is true or false.

Multiple choice
  1. if

  2. while

  3. when

  4. elif

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The 'while' statement is a control structure used for iteration, meaning it repeats a block of code as long as a specified condition remains true.