MCQS from C Programming Language set 51-75

 51. What is the value of sizeof(char) in C?

A) 1 byte
B) 2 bytes
C) 4 bytes
D) Compiler-dependent
Answer: A) 1 byte


52. What is the function of fflush(stdin); in C?
A) Clears the input buffer
B) Clears the output buffer
C) Clears both input and output buffers
D) None of the above
Answer: A) Clears the input buffer


53. How do you declare a pointer to an array of integers?
A) int *arr;
B) int (*arr)[10];
C) int arr[10];
D) int **arr;
Answer: B) int (*arr)[10];


54. Which operator is used to get the address of a variable?
A) *
B) &
C) ->
D) @
Answer: B) &


55. What does p++ do if p is a pointer?
A) Moves to the next byte
B) Moves to the next memory location based on data type
C) Moves to the previous memory location
D) Results in a compilation error
Answer: B) Moves to the next memory location based on data type


56. What will be the output of printf("%d", 5 & 3);?
A) 1
B) 2
C) 3
D) 5
Answer: B) 1


57. What is a volatile keyword used for in C?
A) To define a variable that can change at any time
B) To create a constant variable
C) To optimize memory allocation
D) To define a floating-point number
Answer: A) To define a variable that can change at any time


58. Which function is used to copy one string into another?
A) strcopy()
B) strcpy()
C) copystr()
D) stringcopy()
Answer: B) strcpy()


59. Which format specifier is used for double type?
A) %d
B) %lf
C) %f
D) %dbl
Answer: B) %lf


60. What does the enum keyword define in C?
A) A user-defined data type
B) A loop structure
C) A function pointer
D) A macro
Answer: A) A user-defined data type


61. Which loop is guaranteed to execute at least once?
A) for
B) while
C) do-while
D) foreach
Answer: C) do-while


62. Which of the following is a logical operator in C?
A) &&
B) &
C) |
D) %
Answer: A) &&


63. What will be the output of printf("%d", sizeof(10.5));?
A) 2
B) 4
C) 8
D) Compiler-dependent
Answer: C) 8


64. What is the purpose of #ifdef in C?
A) It checks if a macro is defined
B) It includes a file
C) It defines a new function
D) It declares a variable
Answer: A) It checks if a macro is defined


65. What does free() function do?
A) Allocates memory
B) Frees dynamically allocated memory
C) Declares a pointer
D) None of the above
Answer: B) Frees dynamically allocated memory


66. What is the output of printf("%d", 10 | 2);?
A) 8
B) 10
C) 12
D) 2
Answer: C) 12


67. What will sizeof(3.14f) return?
A) 2
B) 4
C) 8
D) Compiler-dependent
Answer: B) 4


68. What is the maximum number of elements in an array declared as int arr[100];?
A) 100
B) 99
C) 101
D) Compiler-dependent
Answer: A) 100


69. Which function is used to concatenate two strings?
A) strcat()
B) strcombine()
C) concat()
D) strmerge()
Answer: A) strcat()


70. Which is the correct syntax for declaring a pointer to a character?
A) char *p;
B) char p*;
C) char &p;
D) pointer char p;
Answer: A) char *p;


71. Which of the following is a storage class specifier in C?
A) auto
B) register
C) static
D) All of the above
Answer: D) All of the above


72. What is the file extension for a C source file?
A) .cpp
B) .java
C) .c
D) .py
Answer: C) .c


73. What is the precedence of the ! operator in C?
A) Highest
B) Low
C) Medium
D) Compiler-dependent
Answer: A) Highest


74. How do you access the value pointed to by a pointer?
A) *ptr
B) &ptr
C) ptr*
D) ptr&
Answer: A) *ptr


75. How do you define a macro in C?
A) #define MAX 100
B) macro MAX 100
C) def MAX 100
D) set MAX 100
Answer: A) #define MAX 100

Previous Post Next Post

نموذج الاتصال