Pointers

6

Are the three declarations char **apple, char *apple[], and char apple[][] same?

A. True
B. False

7

The following program reports an error on compilation.

#include<stdio.h>
int main()
{
    float i=10, *j;
    void *k;
    k=&i;
    j=k;
    printf("%f\n", *j);
    return 0;
}
A. True
B. False

8

Are the expression *ptr++ and ++*ptr are same?

A. True
B. False

9

In the following program add a statement in the function fact() such that the factorial gets stored in j.

#include<stdio.h>
#include
void fact(int*);

int main()
{
    int i=5;
    fact(&i);
    printf("%d\n", i);
    return 0;
}
void fact(int *j)
{
    static int s=1;
    if(*j!=0)
    {
        s = s**j;
        *j = *j-1;
        fact(j);
        /* Add a statement here */
    }
}
A. j=s;
B. *j=s;
C. *j=&s;
D. &j=s;

10

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