Skip to main content

Important Introduction to Programming Short Questions

Chapter: 9
Question 1:
What does the statement result = square(number) + square(3) do?
Answer: This statement calls the square function twice, squares number and 3, and adds the results together, assigning it to result.
Chapter: 10
Question 2:
What is a header file in C/C++?
Answer: A header file in C/C++ is a file containing function prototypes, constants, and other declarations.
Chapter: 10
Question 3:
Why are header files used?
Answer: Header files are used to simplify the inclusion of frequently used functions and constants.
Chapter: 10
Question 4:
How do you include a header file in a C/C++ program?
Answer: You include a header file using the #include directive, e.g., #include "headerfile.h".
Chapter: 10
Question 5:
What is a function prototype?
Answer: A function prototype is a declaration of a function that specifies the function’s name, return type, and parameters.
Chapter: 10
Question 6:
Why is #define used in header files?
Answer: #define is used to define constants in a program, making the code more readable and maintainable.
Chapter: 10
Question 7:
What is a local variable?
Answer: A local variable is a variable declared within a function or block, visible only within that scope.
Chapter: 10
Question 8:
What is a global variable?
Answer: A global variable is a variable declared outside any function, accessible throughout the program.
Chapter: 10
Question 9:
What is scope of a variable?
Answer: The scope of a variable refers to the part of the program where the variable is accessible.
Chapter: 10
Question 10:
What is the difference between local and global variables?
Answer: Local variables are accessible only within the block where they are declared, while global variables are accessible throughout the program.