Pointer MCQs

253 questionsC-ProgramPage 13 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 109easy
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char *str = "hello, world\n";
    char *strc = "good morning\n";
    strcpy(strc, str);
    printf("%s\n", strc);
    return 0;
}
Question 110easy
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    char *s = "hello";
    char *p = s;
    printf("%c\t%c", *p, s[1]);
}
Question 111easy
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char **p = {"hello", "hi", "bye"};
    printf("%s", (p)[0]);
    return 0;
}
Advertisement
Question 112easy
What will be the output of the following C code?
#include <stdio.h>
struct student
{
    int no;
    char name[20];
};
struct student s;
void main()
{
    s.no = 8;
    printf("%s", s.name);
}
Question 113easy
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 0, j = 1;
    int *a[] = {&i, &j};
    printf("%d", (*a)[0]);
    return 0;
}
Question 114easy
What will be the output of the following C code?
#include <stdio.h>
int add(int a, int b)
{
    return a + b;
}
int main()
{
    int (*fn_ptr)(int, int);
    fn_ptr = add;
    printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
}
Advertisement
Question 115easy
What will be the output of the following C code?
#include <stdio.h>
void (*(f)())(int, float);
void (*(*x)())(int, float) = f;
void ((*y)(int, float));
void foo(int i, float f);
int main()
{
    y = x();
    y(1, 2);
}
void (*(f)())(int, float)
{
    return foo;
}
void foo(int i, float f)
{
    printf("%d %f\n", i, f);
}
Question 116easy
What substitution should be made to //-Ref such that ptr1 points to variable c in the following C code?
#include <stdio.h>
int main()
{
    int a = 1, b = 2, c = 3;
    int *ptr1 = &a
    int **sptr = &ptr1
    //-Ref
}
Question 117easy
What will be the output of the following C code?
#include <stdio.h>
void foo(int*);
int main()
{
    int i = 10;
    foo((&i)++);
}
void foo(int *p)
{
    printf("%d\n", *p);
}