Top

Strings

91.

What will be the output of the program ?

#include
#include

int main()
{
    static char s[] = "Hello!";
    printf("%d\n", *(s+strlen(s)));
    return 0;
}

 

Answer:

Enter details here

92.

What will be the output of the program ?

#include
#include

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

 

Answer: A

No answer description available for this question.

Enter details here

93.

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

94.

What does the following fragment of C-program print?

char c[] = "GATE2011";  
char *p =c;  
printf("%s", p + p[3] - p[1]) ; 

 

Answer: C

No answer description available for this question.
 

Enter details here

Answer: C

Functions whose names begin with “strn” manipulates the sequence of non-null characters.

Enter details here

96.

What will be the output of the following C code?

char str1[] = "Helloworld ";
char str2[] = "Hello";
len = strspn(str1, str2);
printf("Length of initial segment matching %d\n", len );

 

Answer: B

The length of the maximum initial segment of the string str1 which consists entirely of characters from the string str2 is computed by strspn().

Enter details here

97.

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

98.

Which of the following function sets first n characters of a string to a given character?

Answer: B

No answer description available for this question.

Enter details here

99.

What will be the output of the following C code?

void *memset(void *c, int c, size-t n) 
unsigned char ch = c;
unsigned char *su;
for (su = s; 0 < n>
*su = ch;

 

Answer: A

This is the safe way to store the same value throughout a contiguous sequence of elements in a character array.

Enter details here

100.

The function strsp() is the complement of strcspn().

Answer: A

Both strcspn() and strpbrk() perform the same function. Only strspn() the return values differ. The function strspn() is the complement of strcspn() .

Enter details here

Loading…
Tags: Strings Questions and Answers || Strings MCQ Questions and Answers || Strings GK Questions and Answers || Strings GK MCQ Questions || Strings Multiple Choice Questions and Answers || Strings GK || GK on Strings || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming