IndiaBIX.com
Search

C Programming - Strings

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

Exercise

"Example is better than precept."
- (Proverb)
16. 

If char=1, int=4, and float=4 bytes size, What will be the output of the program ?

#include<stdio.h>

int main()
{
    char ch = 'A';
    printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));
    return 0;
}

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

17. 

If the size of pointer is 32 bits What will be the output of the program ?

#include<stdio.h>

int main()
{
    char a[] = "Visual C++";
    char *b = "Visual C++";
    printf("%d, %d\n", sizeof(a), sizeof(b));
    printf("%d, %d", sizeof(*a), sizeof(*b));
    return 0;
}

A. 10, 2
2, 2
B. 10, 4
1, 2
C. 11, 4
1, 1
D. 12, 2
2, 2

18. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    static char mess[6][30] = {"Don't walk in front of me...", 
                               "I may not follow;", 
                               "Don't walk behind me...", 
                               "Just walk beside me...", 
                               "And be my friend." };

    printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9));
    return 0;
}

A. t, tB. k, k
C. n, kD. m, f

19. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char str1[] = "Hello";
    char str2[10];
    char *t, *s;
    s = str1;
    t = str2;
    while(*t=*s)
        *t++ = *s++;
    printf("%s\n", str2);
    return 0;
}

A. HelloB. HelloHello
C. No outputD. ello

20. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char str[] = "India\0BIX\0";
    printf("%d\n", sizeof(str));
    return 0;
}

A. 10B. 6
C. 5D. 11




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

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