Pointers - Point Out Correct Statements Multiple Questions and Answers.
Exercise Questions ::
Pointers
1. | Which of the statements is correct about the program? |
|
#include<stdio.h>
int main()
{
int i=10;
int *j=&i;
return 0;
}
|
| A. | j and i are pointers to an int |
| B. | i is a pointer to an int and stores address of j |
| C. | j is a pointer to an int and stores address of i |
| D. | j is a pointer to a pointer to an int and stores address of i |
|
|
Published by:Michael Daani
2. | Which of the statements is correct about the program? |
|
#include<stdio.h>
int main()
{
float a=3.14;
char *j;
j = (char*)&a;
printf("%d\n", *j);
return 0;
}
|
| A. | It prints ASCII value of the binary number present in the first byte of a float variable a. |
| B. | It prints character equivalent of the binary number present in the first byte of a float variable a. |
| C. | It will print 3 |
| D. | It will print a garbage value |
|
|
Published by:Michael Daani
3. | In the following program add a statement in the function fun() such that address of a gets stored in j? |
|
#include<stdio.h>
int main()
{
int *j;
void fun(int**);
fun(&j);
return 0;
}
void fun(int **k)
{
int a=10;
}
|
| A. | **k=a; |
| B. | k=&a; |
| C. | *k=&a |
| D. | &k=*a |
|
|
Published by:Michael Daani
4. | Which of the following statements correct about k used in the below statement? |
| |
| A. | k is a pointer to a pointer to a pointer to a char |
| B. | k is a pointer to a pointer to a pointer to a pointer to a char |
| C. | k is a pointer to a char pointer |
| D. | k is a pointer to a pointer to a char |
|
|
Published by:Michael Daani
5. | Which of the statements is correct about the program? |
|
#include<stdio.h>
int main()
{
int arr[3][3] = {1, 2, 3, 4};
printf("%d\n", *(*(*(arr))));
return 0;
}
|
| A. | Output: Garbage value |
| B. | Output: 1 |
| C. | Output: 3 |
| D. | Error: Invalid indirection |
|
|
Published by:Michael Daani
»