C Programming - Mock Interview Test
1. What is the correct syntax for printing a string in C?
A. printf("Hello World");
B. print("Hello World");
C. System.out.print("Hello World");
D. None of the above
2. Which operator is used to assign a value to a variable in C?
a) ==
b) =
c) :=
d) #
3. What is the correct syntax for a for loop in C?
a) for (i = 0; i < 5; i++)
b) for i = 0 to 5
c) for (i = 0; i < 5; i++)
d) None of the above
4. Which of the following is the correct way to declare an integer variable in C?
a) int num;
b) integer num;
c) num int;
d) None of the above
5. Which of the following is used to terminate a loop in C?
a) exit
b) break
c) continue
d) return
6. What is the default value of a static variable in C?
a) 0
b) Undefined
c) 1
d) NULL
7. Which header file is required to use the printf function in C?
a) conio.h
b) stdio.h
c) stdlib.h
d) math.h
8. What is the correct way to declare a pointer in C?
A. int *ptr;
B. ptr int;
C. int ptr*;
D. None of the above
9. What is the size of an int in C?
A. 8 bytes
B. 4 bytes
C. 2 bytes
D. 1 bytes
10. Which of the following is used to allocate memory dynamically in C?
A. Malloc
B. Calloc
C. Realloc
D. All of the above
11. Which keyword is used to declare a constant in C?
A. static
B. const
C. constant
D. final
12. Which function is used to get the length of a string in C?
A. length()
B. strlength()
C. strlen()
D. size()
13. Which of the following is correct for a function in C?
A. It should have a return type
B. It should always take arguments
C. It should have a name
D. All of the above
14. Which of the following is used for multi-line comments in C?
A. /* comment */
B. // comment
C. # comment
D. -- comment
15. What is the correct syntax to define a function in C?
A. void function_name() { }
B. function_name() void { }
C. def function_name() { }
D. None of the above
16. How do you declare an array in C?
A. int arr[5];
B. int arr(5);
C. array int[5];
D. None of the above
17. Which function is used to copy a string in C?
A. strcpy()
B. copy()
C. strcat()
D. strncpy()
18. Which of the following is correct for including a standard header file in C?
A. #include
B. include
C. include "stdio.h"
D. #include "stdio.h"
19. What is the result of the expression 5 + 3 * 2 in C?
A. 16
B. 11
C. 13
D. 10
20. Which function is used to open a file in C?
A. fopen()
B. open()
C. fileopen()
D. None of the above
Submit
Go Back