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

2/13

Page

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

What is the result of the expression ptr-- in C, where ptr is a pointer?

Select an option to see the answer and solution.

In C, what is a function pointer?

Select an option to see the answer and solution.

What is the result of the expression &array[0] in C, where array is an integer array?

Select an option to see the answer and solution.

In C, what is a null pointer (NULL or 0)?

Select an option to see the answer and solution.

What is the result of the expression ptr += 2 in C, where ptr is a pointer?

Select an option to see the answer and solution.

In C, what is the purpose of the 'calloc' function?

Select an option to see the answer and solution.

What is the result of the expression *ptr = 42 in C, where ptr is a pointer to an int?

Select an option to see the answer and solution.

In C, what is a pointer to a function that takes no arguments and returns an integer?

Select an option to see the answer and solution.

What is the result of the expression *ptr = NULL in C, where ptr is a pointer?

Select an option to see the answer and solution.

In C, what is a pointer to a constant pointer (int* const)?

Select an option to see the answer and solution.

Determine Output:
void main()
{
      char far *farther, *farthest;
      printf("%d..%d", sizeof(farther), sizeof(farthest));
}

Select an option to see the answer and solution.

Determine Output:
main()
{
      char *str1 = "abcd";
      char str2[] = "abcd";
      printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));
}

Select an option to see the answer and solution.

Choose the best answer.
Prior to using a pointer variable

Select an option to see the answer and solution.

Comment on the following pointer declaration?
int *ptr, p;

Select an option to see the answer and solution.

What will be the output?
main() 
{ 
      char *p; 
      p = "Hello"; 
      printf("%cn",*&*p); 
}

Select an option to see the answer and solution.

Determine output:
#include <stdio.h>
void main()
{
      char *p = NULL;
      char *q = 0;
      if(p)
            printf(" p ");
      else
            printf("nullp");
      if(q)
            printf("q");
      else
            printf(" nullq");
}

Select an option to see the answer and solution.

The address operator &, cannot act on

Select an option to see the answer and solution.

The statement int **a;

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.