IndiaBIX.com
Search

C Programming - Pointers

@ : Home > C Programming > Pointers > Find Output of Program

Exercise

"Act well your part; there all honor lies."
- Alexander Pope
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;
}

A. inkB. ack
C. iteD. let

2. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    int i=3, *j, k;
    j = &i;
    printf("%d\n", i**j*i+*j);
    return 0;
}

A. 30B. 27
C. 9D. 3

3. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    int x=30, *y, *z;
    y=&x; /* Assume address of x is 500 and integer is 4 byte size */
    z=y;
    *y++=*z++;
    x++;
    printf("x=%d, y=%d, z=%d\n", x, y, z);
    return 0;
}

A. x=31, y=502, z=502B. x=31, y=500, z=500
C. x=31, y=498, z=498D. x=31, y=504, z=504

4. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char str[20] = "Hello";
    char *const p=str;
    *p='M';
    printf("%s\n", str);
    return 0;
}

A. MelloB. Hello
C. HMelloD. MHello

5. 

What will be the output of the program If the integer is 4bytes long?

#include<stdio.h>

int main()
{
    int ***r, **q, *p, i=8;
    p = &i;
    q = &p;
    r = &q;
    printf("%d, %d, %d\n", *p, **q, ***r);
    return 0;
}

A. 8, 8, 8B. 4000, 4002, 4004
C. 4000, 4004, 4008D. 4000, 4008, 4016




© 2008-2014 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Contact us: info@indiabix.com     Follow us on twitter!