Important Introduction to Programming Short Questions
Chapter: 5
Question 1:
How does integer division affect the calculation in C programming?
Answer:
Integer division truncates the result to an integer, potentially leading to incorrect calculations, especially when dealing with percentages or ratios.
Chapter: 5
Question 2:
What is a logical error in programming?
Answer:
A logical error occurs when the program compiles and runs, but produces incorrect results due to flaws in the logic of the code.
Chapter: 5
Question 3:
How does an 'if statement' differ from an 'if/else' statement in C?
Answer:
An 'if statement' executes code only when a condition is true, while an 'if/else' statement provides alternative code to execute when the condition is false.
Chapter: 5
Question 4:
Why is it a good practice to initialize variables in C programming?
Answer:
It prevents unexpected results due to uninitialized variables that might contain garbage values, leading to more predictable and correct program behavior.
Chapter: 5
Question 5:
What is a unary operator in C programming?
Answer:
A unary operator in C takes a single operand and performs an operation, like the logical negation operator (!), which inverts the truth value of its operand.
Chapter: 5
Question 6:
How does a block of statements improve the clarity of an 'if statement' in C?
Answer:
A block of statements groups related operations together, making the code easier to read, understand, and ensuring that all statements are executed together when the condition is true.
Chapter: 6
Question 7:
What is a repetition structure in programming?
Answer:
A repetition structure allows a set of instructions to be executed repeatedly under certain conditions.
Chapter: 6
Question 8:
Why is repetition useful in programming?
Answer:
Repetition is useful for automating repetitive tasks, like summing a series of numbers, which would be tedious to write manually.
Chapter: 6
Question 9:
What is the limitation of using a single statement to add multiple numbers?
Answer:
Using a single statement becomes impractical for adding a large number of digits, as it results in a cumbersome and error-prone code.
Chapter: 6
Question 10:
How can you find the next integer in a sequence?
Answer:
To find the next integer, you simply add 1 to the current integer.