Strings

11

What will be the output of the program ?

#include<stdio.h>
#include<string.h>

int main()
{
    char sentence[80];
    int i;
    printf("Enter a line of text\n");
    gets(sentence);
    for(i=strlen(sentence)-1; i >=0; i--)
        putchar(sentence[i]);
    return 0;
}
A. The sentence will get printed in same order as it entered
B. The sentence will get printed in reverse order
C. Half of the sentence will get printed
D. None of above

12

What will be the output of the program ?

#include<stdio.h>
int main()
{
    char str[] = "Nagpur";
    str[0]='K';
    printf("%s, ", str);
    str = "Kanpur";
    printf("%s", str+1);
    return 0;
}
A. Kagpur, Kanpur
B. Nagpur, Kanpur
C. Kagpur, anpur
D. Error

13

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. Hello
B. HelloHello
C. No output
D. ello

14

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, t
B. k, k
C. n, k
D. m, f

15

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