Strings

21

What will be the output of the program ?

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

int main()
{
    static char str1[] = "dills";
    static char str2[20];
    static char str3[] = "Daffo";
    int i;
    i = strcmp(strcat(str3, strcpy(str2, str1)), "Daffodills");
    printf("%d\n", i);
    return 0;
}
A. 0
B. 1
C. 2
D. 4

22

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char *names[] = { "Suresh", "Siva", "Sona", "Baiju", "Ritu"};
    int i;
    char *t;
    t = names[3];
    names[3] = names[4];
    names[4] = t;
    for(i=0; i<=4; i++)
        printf("%s,", names[i]);
    return 0;
}
A. Suresh, Siva, Sona, Baiju, Ritu
B. Suresh, Siva, Sona, Ritu, Baiju
C. Suresh, Siva, Baiju, Sona, Ritu
D. Suresh, Siva, Ritu, Sona, Baiju

23

What will be the output of the program If characters 'a', 'b' and 'c' enter are supplied as input?

#include<stdio.h>

int main()
{
    void fun();
    fun();
    printf("\n");
    return 0;
}
void fun()
{
    char c;
    if((c = getchar())!= '\n')
        fun();
    printf("%c", c);
}
A. abc abc
B. bca
C. Infinite loop
D. cba

24

What will be the output of the program ?

#include<stdio.h>

int main()
{
    printf(5+"Good Morning\n");
    return 0;
}
A. Good Morning
B. Good
C. M
D. Morning

25

What will be the output of the program ?

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

int main()
{
    printf("%d\n", strlen("123456"));
    return 0;
}
A. 6
B. 12
C. 7
D. 2