Important Introduction to Programming Short Questions
Chapter: 10
Question 1:
What does "Call by Value" mean in C/C++?
Answer:
"Call by Value" means passing a copy of the variable to the function, so the original variable remains unchanged.
Chapter: 10
Question 2:
What does "Call by Reference" mean in C/C++?
Answer:
"Call by Reference" means passing the address of the variable to the function, allowing the function to modify the original variable.
Chapter: 10
Question 3:
What is a recursive function?
Answer:
A recursive function is a function that calls itself to solve a problem.
Chapter: 10
Question 4:
What is the base case in a recursive function?
Answer:
The base case is the condition under which the recursive function stops calling itself.
Chapter: 10
Question 5:
Why is it important to minimize the use of global variables?
Answer:
Overuse of global variables can lead to unintended side effects and make the program harder to debug.
Chapter: 10
Question 6:
What happens if you declare a variable with the same name in different scopes?
Answer:
If a variable with the same name is declared in different scopes, the innermost scope's variable will hide the outer scope's variable.
Chapter: 10
Question 7:
What is the output of a function that uses "Call by Value"?
Answer:
The original variable remains unchanged, and the function only uses the copied value.
Chapter: 10
Question 8:
What is the potential drawback of using recursive functions?
Answer:
Recursive functions can lead to memory and stack overhead due to repeated function calls.
Chapter: 10
Question 9:
How can a constant be defined in a header file?
Answer:
A constant can be defined in a header file using the #define directive, e.g., #define PI 3.1415926.
Chapter: 10
Question 10:
What is a code block?
Answer:
A code block is a section of code enclosed by {} where variables have local scope.