Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Printf ("%D", 5 + 2 3) : Strlen

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1. Which of the following is considered the brain of the computer?

A) Memory
B) CPU
C) Hard Drive
D) Input Device
Answer: B) CPU
2. Which of the following is a high-level programming language?
A) Assembly
B) C
C) Machine code
D) Binary
Answer: B) C
3. What is the output of the following code?
printf("%d", 5 + 2 * 3);
A) 11
B) 21
C) 15
D) 9
Answer: A) 11

4. Which function is used to read a string input from the user in C?


A) gets()
B) scanf()
C) fgets()
D) puts()
Answer: C) fgets()

5. What function is typically used for input in C?


A) printf
B) scanf
C) input
D) getch
Answer: B) scanf
6. What is the primary purpose of arrays in C?
A) To store single values
B) To store multiple values of the same type
C) To increase program execution speed
D) To manage memory allocation
Answer: B) To store multiple values of the same type
7. What is the primary purpose of the strlen() function in C?
A) To concatenate two strings
B) To convert a string to an integer
C) To determine the length of a string
D) To compare two strings
Answer: C) To determine the length of a string
8. Which of the following is a standard library function in C for calculating the square root?
A) pow()
B) sqrt()
C) root()
D) abs()
Answer: B) sqrt()

9. What is the primary benefit of using functions in programming?


A) They increase complexity
B) They allow code reuse and modularity
C) They eliminate the need for variables
D) They make debugging harder
Answer: B) They allow code reuse and modularity

10. Which of the following is NOT a repetition statement in C?


A) for
B) switch
C) while
D) do-while
Answer: B) switch

11. What does the 'break' statement do within a loop?


A) Skips the current iteration
B) Terminates the loop entirely
C) Continues to the next iteration
D) Restarts the loop
Answer: B) Terminates the loop entirely

12. What are the primary components of a computer system? A) Software and Applications
B) Hardware and Software
C) Data and Information
D) Networks and Protocols

Answer: B) Hardware and Software

12. Which of the following is NOT a type of computing environment? A) Personal


computing
B) Cloud computing
C) Network security
D) Embedded systems
Answer: C) Network security
13. Which of the following is a basic data type in C? A) string
B) int
C) array
D) list
Answer: B) int
14. What will be the result of the expression 5 & 3 in C? A) 5
B) 3
C) 1
D) 0
Answer: C) 1

15. Which of the following is NOT a repetition statement in C? A) while


B) repeat
C) for
D) do-while
Answer: B) repeat

16. Which statement is used to execute a block of code based on a condition in C? A) for
B) if
C) switch
D) both B and C
Answer: D) both B and C

17. A __________ computing environment allows multiple users to access resources and
applications over the internet. Answer: cloud
18. Programming languages are classified into high-level languages and __________
languages. Answer: low-level
19. The keyword used to define a constant value in C is __________. Answer: const
20. The __________ data type in C is used to represent single characters. Answer: char

14. In C, a loop that executes as long as a specified condition is true is called a __________ loop.
Answer: while

21. The __________ statement is used to skip the current iteration of a loop and continue
with the next iteration. Answer: continue
22. The __________ is the part of a function that specifies what value it will return. Answer:
return type
23. In C, arguments passed to a function are known as __________. Answer: parameters
24. The first element of an array is accessed using the index __________. Answer: 0

25. In C, a string is typically represented as an array of characters terminated by a


__________ character. Answer: null (or '\0')
26. The function used to copy one string to another in C is __________. Answer: strcpy
27. In C programming, a __________ is a named storage location in memory that holds a
value. Answer: variable
28. The __________ statement in C allows the execution of multiple conditions by matching
a variable against several values. Answer: switch
29. the __________ statement repeatedly executes a block of code as long as a specified
condition is true. Answer: while

You might also like