Pointer MCQs

253 questionsC-ProgramPage 16 of 29

Practice free Pointer multiple-choice questions with instant answer feedback and step-by-step solutions. Click an option to check yourself, reveal the full explanation, and work through all 253 questions — no login required.

Question 136easy
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int a[4] = {1, 2, 3, 4};
    int *ptr  =  &a[2];
    float n = 1;
    ptr = ptr + n;
    printf("%d\n", *ptr);
}
Question 137easy
What is the size of *ptr in a 32-bit machine (Assuming initialization as int *ptr = 10;)?
Question 138easy
What will be the output of the following C code?
#include <stdio.h>
void f(int (*x)(int));
int myfoo(int);
int (*foo)() = myfoo;
int main()
{
    f(foo);
}
void f(int(*i)(int ))
{
    i(11);
}
int myfoo(int i)
{
    printf("%d\n", i);
    return i;
}
Advertisement
Question 139easy
Comment on the following 2 arrays with respect to P and Q.
int *a1[8];
int *(a2[8]);
P. Array of pointers
Q. Pointer to an array
Question 140easy
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 10;
    void *p = &i
    printf("%f\n", *(float*)p);
    return 0;
}
Question 141easy
Which of the following declaration is illegal?
Advertisement
Question 142easy
What will be the output of the following C code?
#include <stdio.h>
int mul(int a, int b, int c)
{
    return a * b * c;
}
void main()
{
    int (function_pointer)(int, int, int);
    function_pointer = mul;
    printf("The product of three numbers is:%d",
    function_pointer(2, 3, 4));
}
Question 143easy
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int x = 0;
    int *ptr = &x
    printf("%d\n", *ptr);
}
Question 144easy
What is the maximum number of arguments that can be passed in a single function?