IndiaBIX.com
Search

C Programming - Pointers

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

Exercise

"Hold a true friend with both hands."
- (Proverb)
6. 

What will be the output of the program ?

#include<stdio.h>

void fun(void *p);
int i;

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

A. Error: cannot convert from void** to int**
B. Garbage value
C. 0
D. No output

7. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char *str;
    str = "%s";
    printf(str, "K\n");
    return 0;
}

A. ErrorB. No output
C. KD. %s

8. 

What will be the output of the program ?

#include<stdio.h>
int *check(static int, static int);

int main()
{
    int *c;
    c = check(10, 20);
    printf("%d\n", c);
    return 0;
}
int *check(static int i, static int j)
{
    int *p, *q;
    p = &i;
    q = &j;
    if(i >= 45)
        return (p);
    else
        return (q);
}

A. 10
B. 20
C. Error: Non portable pointer conversion
D. Error: cannot use static for function parameters

9. 

What will be the output of the program if the size of pointer is 4-bytes?

#include<stdio.h>

int main()
{
    printf("%d, %d\n", sizeof(NULL), sizeof(""));
    return 0;
}

A. 2, 1B. 2, 2
C. 4, 1D. 4, 2

10. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    void *vp;
    char ch=74, *cp="JACK";
    int j=65;
    vp=&ch;
    printf("%c", *(char*)vp);
    vp=&j;
    printf("%c", *(int*)vp);
    vp=cp;
    printf("%s", (char*)vp+2);
    return 0;
}

A. JCKB. J65K
C. JAKD. JACK




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

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