C/C++ MCQs January 8, 2026August 9, 2024 by u930973931_answers 20 min Score: 0 Attempted: 0/20 Subscribe 1. Which of the following is the correct syntax for defining a function in Python? (A) function name() {} (B) define name() {} (C) func name[] {} (D) def name(): 2. In which programming language is System.out.println() used? (A) Python (B) JavaScript (C) C++ (D) Java 3. What is the output of print(“Hello” + ” World”) in Python? (A) HelloWorld (B) Hello World (C) Hello + World (D) Hello World 4. Which of the following is not a valid data type in Python? (A) char (B) string (C) boolean (D) int 5. What does the following Python code do? list(range(5)) (A) Creates a list of integers from 0 to 4 (B) Creates a list of integers from 1 to 5 (C) Creates a list of integers from 1 to 4 (D) Creates a list of integers from 0 to 5 6. What is the output of 2**3 in Python? (A) 8 (B) 6 (C) 9 (D) 16 7. How do you declare a variable in JavaScript? (A) variable name = value; (B) var name = value; (C) let name := value; (D) define name = value; 8. What is the correct way to comment a single line in C++? (A) # comment (B) // comment (C) — comment (D) /* comment */ 9. In which language is for loop syntax for (int i = 0; i < 10; i++) used? (A) JavaScript (B) C++ (C) Python (D) Java 10. What will be the output of print(0.1 + 0.2 == 0.3) in Python? (A) True (B) None (C) False (D) Error 11. Which operator is used for string concatenation in JavaScript? (A) & (B) + (C) (D) * 12. What is the purpose of the return statement in a function? (A) To end the function (B) To pass data to the function (C) To send data back from the function (D) To call another function 13. How do you create an array in Python? (A) array = [] (B) array = {} (C) array = () (D) array = [] 14. Which of the following is a correct syntax to declare a variable in Python? (A) var name = value (B) name = value (C) let name: value (D) name: value 15. What is the output of console.log(typeof null) in JavaScript? (A) object (B) null (C) undefined (D) boolean 16. Which of the following keywords is used to define a class in Java? (A) function (B) define (C) class (D) struct 17. What does the break statement do in a loop? (A) Ends the loop (B) Skips the current iteration (C) Continues to the next iteration (D) Repeats the loop 18. How do you add a comment in JavaScript? (A) (B) /* comment */ (C) # comment (D) // comment 19. What will the expression 10 % 3 evaluate to? (A) 1 (B) 3 (C) 10 (D) 0 20. How do you create a dictionary in Python? (A) dict = [] (B) dict = < > (C) dict = () (D) dict = {}