C - Pointers


Question 1     

What will be the output of the program ?

#include<stdio.h>

int main()
{
          static char *s[] = {"black", "white", "pink", "violet"};
          char **ptr[] = {s+3, s+2, s+1, s}, ***p;
          p = ptr;
          ++p;
          printf("%s", **p+1);
          return 0;
}





Question 2     

What will be output of following program?

void print(int *ptr)
{
    *ptr = 65;
}
int main()
{
     int x = 60;
     print(&x);
     printf("%d", x);
     return 0;
}





Question 3     

State the equivalent pointer expression which refer the given array element a[i][j][k][l]?






Question 4     

What will be output of following program?

#include <stdio.h>
int main() {
int a = 10;
void *p = &a;
int *ptr = p;
printf(“%u”,*ptr);
return 0;
}





Question 5     

What is the output of the program?

int main()
{
char *a = NULL;
char *b = 0;
if (a)
printf(" A ");
else
printf("null A");
if (!b)
printf("B\n");
else
printf(" null B\n");
}





Question 6     

What is the output of the program?

int main()
{
int i = 10;
void *p = &i;
printf("%f\n", *(float*)p);
return 0;
}





Question 7     

What will be the output of the program?

int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int *j = (int*)malloc(sizeof(int));
*j = 10;
return j;
}





Question 8     

What will be the output of the program?

int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int j = 10;
return &j;
}





Question 9     

Choose the best answer. Prior to using a pointer variable







Sign Up Page

Oops!!

To view the solution need to Login



Score : 0 / 0
L
o
a
d
i
n
g
.
.
.