Top

Strings

1.

What will be the output of the program ?

#include
#include

int main()
{
    char str1[5], str2[5];
    int i;
    gets(str1);
    gets(str2);
    i = strcmp(str1, str2);
    printf("%d\n", i);
    return 0;
}

 

Answer: A

No answer description available for this question.

Enter details here

2.

What will be the output of the program ?

#include

int main()
{
    int i;
    char a[] = "\0";
    if(printf("%s", a))
        printf("The string is not empty\n");
    else
        printf("The string is empty\n");
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

3.

If the size of pointer is 4 bytes then What will be the output of the program ?

#include

int main()
{
    char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"};
    printf("%d, %d", sizeof(str), strlen(str[0]));
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

4.

What will be the output of the program (Turbo C in 16 bit platform DOS) ?

#include
#include

int main()
{
    char *str1 = "India";
    char *str2 = "BIX";
    char *str3;
    str3 = strcat(str1, str2);
    printf("%s %s\n", str3, str1);
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

5.

What will be the output of the program ?

#include
void swap(char *, char *);

int main()
{
    char *pstr[2] = {"Hello", "IndiaBIX"};
    swap(pstr[0], pstr[1]);
    printf("%s\n%s", pstr[0], pstr[1]);
    return 0;
}
void swap(char *t1, char *t2)
{
    char *t;
    t=t1;
    t1=t2;
    t2=t;
}

 

Answer: C

No answer description available for this question.

Enter details here

Loading…