Vidyalelo
C Programming · all questions

Pointer
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

253

Questions

8/13

Page

Pick an option on a question to see the right answer and solution.

Which of the following declaration is illegal?

Select an option to see the answer and solution.

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));
}

Select an option to see the answer and solution.

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);
}

Select an option to see the answer and solution.

What is the maximum number of arguments that can be passed in a single function?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int ary[4] = {1, 2, 3, 4};
    int p[4];
    p = ary;
    printf("%d\n", p[1]);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int *((*x)())[2];
    x();
    printf("after x\n");
}
int *((*x)())[2]
{
    int **str;
    str = (int*)malloc(sizeof(int)* 2);
    return str;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int k = 5;
    int *p = &k;
    int **m  = &p;
    **m = 6;
    printf("%d\n", k);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int *f();
int main()
{
    int *p = f();
    printf("%d\n", *p);
}
int *f()
{
    int j = 10;
    return &j;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
struct student
{
    int no;
    char name[20];
};
void main()
{
    student s;
    s.name = "hello";
    printf("hello");
}

Select an option to see the answer and solution.

Which of the following are generated from char pointer?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void f(char *k)
{
    k++;
    k[2] = 'm';
    printf("%c\n", *k);
}
void main()
{
    char s[] = "hello";
    f(s);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void f(int);
void (*foo)(float) = f;
int main()
{
    foo(10);
}
void f(int i)
{
    printf("%d\n", i);
}

Select an option to see the answer and solution.

Which of the following is the correct syntax to declare a 3 dimensional array using pointers?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    char *s = "hello";
    char *n = "cjn";
    char *p = s + n;
    printf("%c\t%c", *p, s[1]);
}

Select an option to see the answer and solution.

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));
}

Select an option to see the answer and solution.

Comment on the output of the following C code.
#include <stdio.h>
int main()
{
    char *str = "This" //Line 1
    char *ptr = "Program\n"; //Line 2
    str = ptr; //Line 3
    printf("%s, %s\n", str, ptr); //Line 4
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char *a = {"p", "r", "o", "g", "r", "a", "m"};
    printf("%s", a);
}

Select an option to see the answer and solution.

What will be the output of the following C code (run without any command line arguments)?
#include <stdio.h>
int main(int argc, char *argv[])
{
    while (argv != NULL)
    printf("%s\n",  *(argv++));
    return 0;
}

Select an option to see the answer and solution.

Read the following expression?
void (*ptr)(int);

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int a[3] = {1, 2, 3};
    int *p = a;
    int **r = &p;
    printf("%p %p", *r, a);
}

Select an option to see the answer and solution.