C Programming - MCQ Practice Questions
Practice free C Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.
978 questions | 100% Free
Consider: int x = 10; int *p = &x; What does the expression *p represent?
Which operator is used to get the address of a variable?
What will be printed by the code: char *ptr = "Hello"; printf("%c", *ptr);
A void pointer can be used to store addresses of variables of any data type. However, it must be cast before dereferencing. Which statement about void pointers is FALSE?
Consider the code: int arr[] = {5, 10, 15, 20}; int *ptr = arr; ptr++; What does ptr now point to?
Which of the following best describes a dangling pointer situation?
Consider: int x = 5; int *p = &x; int q = &p; What is the value of q?
Which memory allocation function does NOT initialize allocated memory to zero?
Consider: int arr[5] = {1, 2, 3, 4, 5}; int *p = arr; What is the value of *(p+2)?
A function needs to modify a variable in the calling function. Which parameter passing method is appropriate?
Consider: void func(int *arr, int size); This function prototype suggests that func will:
What will be the output of: int x = 10; int *p = &x; printf("%p", p); (assuming typical system output)
In a function that returns a pointer, which of the following is UNSAFE?
Consider: int *p = (int *)malloc(5 * sizeof(int)); for(int i=0; i<5; i++) *(p+i) = i*10; Which statement correctly deallocates this memory?
A programmer uses a pointer variable but forgets to initialize it before dereferencing. Which type of error will occur?
What is the size of a pointer variable in a 64-bit system?
What does the & operator do when used with a variable?
What is the output of the following code? int x = 20; int *p = &x; printf("%d", *p);
Which of the following is a void pointer?
What is the difference between pointer and array name in C?