Computer Science Mcqs
Computer Science Mcqs
10. What should be done after understanding the problem and solving it?
A. Forget about the problem
B. Test the solution with multiple cases, including edge cases
C. Optimize without testing
D. Write the documentation immediately
Answer: B. Test the solution with multiple cases, including edge cases
1. What is an algorithm?
Answer: A set of steps or rules to solve a problem.
5. What is a pointer in C?
Answer: A variable that stores the memory address of another variable.
7. What is an API?
Answer: Application Programming Interface; it allows different software programs to
communicate with each other.
4. Which language uses the JVM (Java Virtual Machine) for execution?
Answer: Java.
10. What is the primary use of the main() function in C and C++?
Answer: It serves as the entry point of the program where execution begins.
2. Which of the following is the correct way to declare the main function in
a C program?
a) int main:
b) void main()
c) int main()
d) main(int)
Answer: c) int main()
10. What is the purpose of the return 0; statement in the main() function?
a) To print a value
b) To indicate successful program termination
c) To define a constant
d) To create a new variable
Answer: b) To indicate successful program terminatio
. What is the first line of a C program typically?
a) Function declaration
b) Include directive
c) Variable declaration
d) Main function
Answer: b) Include directive
2. Which of the following is the correct way to declare the main function in
a C program?
a) int main:
b) void main()
c) int main()
d) main(int)
Answer: c) int main()
10. What is the purpose of the return 0; statement in the main() function?
a) To print a value
b) To indicate successful program termination
c) To define a constant
d) To create a new variable
Answer: b) To indicate successful program termination
This quiz covers key aspects of the structure of a C program and its components.
4o mini
You said:
mcqs and quiz constant and variable
ChatGPT said:
ChatGPT
Here’s a quiz with multiple-choice questions (MCQs) focused on constants and
variables in programming, specifically in C:
3. What is a constant?
a) A variable that can change its value
b) A fixed value that does not change during program execution
c) A type of function
d) A special operator
Answer: b) A fixed value that does not change during program execution
8. What will happen if you try to change the value of a constant after it
has been declared?
a) The program will compile successfully.
b) The program will throw a runtime error.
c) The program will throw a compilation error.
d) The value will change without any error.
Answer: c) The program will throw a compilation error.
10. Which of the following correctly shows how to use a variable in a printf
statement?
a) printf("Value: %d", value);
b) printf("Value: value");
c) printf("Value: %s", value);
d) printf("Value: (value)");
Answer: a) printf("Value: %d", value);