Pointers

21

What will be the output of the program ?

#include<stdio.h>
power(int**);
int main()
{
    int a=5, *aa; /* Address of 'a' is 1000 */
    aa = &a;
    a = power(&aa);
    printf("%dn", a);
    return 0;
}
power(int **ptr)
{
    int b;
    b = **ptr***ptr;
    return (b);
}
A. 5
B. 25
C. 125
D. Garbage value

22

What will be the output of the program assuming that the array begins at location 1002?

#include<stdio.h>

int main()
{
    int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2}, 
                       {2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} };
    printf("%u, %u, %u, %d\n", a, *a, **a, ***a);
    return 0;
}
A. 1002, 2004, 4008, 2
B. 2004, 4008, 8016, 1
C. 1002, 1002, 1002, 1
D. Error

23

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char *p;
    p="hello";
    printf("%s\n", *&*&p);
    return 0;
}
A. llo
B. hello
C. ello
D. h

24

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char str[] = "peace";
    char *s = str;
    printf("%s\n", s++ +3);
    return 0;
}
A. peace
B. eace
C. ace
D. ce

25

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char *str;
    str = "%d\n";
    str++;
    str++;
    printf(str-2, 300);
    return 0;
}
A. No output
B. 30
C. 3
D. 300