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

11/13

Page

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

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

Select an option to see the answer and solution.

Which is an indirection operator among the following?

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 *a[10] = {"hi", "hello", "how"};
    int i = 0;
    for (i = 0;i < 10; i++)
    printf("%s", a[i]);
}

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 *p = s + 2;
    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>
void main()
{
    int k = 5;
    int *p = &k;
    int **m  = &p;
    printf("%d%d%d\n", k, *p, **p);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void foo(int (*ary)[3]);
int main()
{
    int ary[2][3];
    foo(ary);
}
void foo(int (*ary)[3])
{
    int i = 10, j = 2, k;
    ary[0] = &i;
    ary[1] = &j;
    for (k = 0;k < 2; k++)
    printf("%d\n", *ary[k]);
}

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[1] = {"hello"};
    printf("%s", a[0]);
    return 0;
}

Select an option to see the answer and solution.

What does this declaration say?
int (*(*y)())[2];

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int x = 0;
void main()
{
    int *const ptr = &x;
    printf("%p\n", ptr);
    ptr++;
    printf("%p\n ", ptr);
}

Select an option to see the answer and solution.

Comment on the following declaration.
int (*ptr)(); // i)
char *ptr[]; // ii)

Select an option to see the answer and solution.

How many number of pointer (*) does C have against a pointer variable declaration?

Select an option to see the answer and solution.

Which type of variables can have the same name in a different function?

Select an option to see the answer and solution.

Which is true for a, if a is defined as "int a[10][20];"?

Select an option to see the answer and solution.

Which of the following expression is true for the following C statement?
ptr is array with 3 elements of pointer to function returning pointer of int

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[2][6] = {"hello", "hi"};
    printf("%d", sizeof(a));
    return 0;
}

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 a[4] = {1, 2, 3, 4};
    void *p = &a[1];
    void *ptr = &a[2];
    int n = 1;
    n = ptr - p;
    printf("%d\n", n);
}

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("%p\n", ptr);
    ptr++;
    printf("%p\n ", ptr);
}

Select an option to see the answer and solution.

What does argc and argv indicate in command-line arguments?
(Assuming: int main(int argc, char *argv[]) )

Select an option to see the answer and solution.

What are the applications of a multidimensional array?

Select an option to see the answer and solution.

What is the second argument in command line arguments?

Select an option to see the answer and solution.