C String MCQ Questions

C language string quiz

1 / 10

Which of the below function is used to find the first occurrence of the substring in the string?

2 / 10

What is the o/p of below c program?

#include<stdio.h>

#include<string.h>

int main()

{

     char *str1 = "embedded";

     char *str2 = "kernel";

     strcat(str1, str2);

     printf("%s", str1);

}

3 / 10

What is the o/p of the below c program?

#include<stdio.h>

int main()

{

     char str1[10] = "World";

     char str2[10] = "World";

     printf("Both the strings are %s", str1==str2 ? "Same" : "Not Same");

}

4 / 10

What is the o/p of the below c program?

#include<stdio.h>

int main()

{

     char *str1 = "kernel";

     char str2[] = "embedded";

     printf("%c %c\n", str1, str2);

}

5 / 10

What is the o/p of the below c program?

#include<stdio.h>

int main()

{

     char *str1 = "embedded";

     char *str2 = "kernel";

     printf("%s %s\n", ++str1, str2++);

}

6 / 10

What is the o/p of the below c program?

#include<stdio.h>

int main()

{

     char str[20] = "abcdefghijk";

     printf("%s %s %c %c\n", str, str+4, *(str+2), str[3]);

}

7 / 10

Will below program compile?

#include<stdio.h>

int main()

{

     char str1[20] = "embedded";

     char *str2 = "kernel";

     str1++;

     str2++;
}

8 / 10

What is the o/p of the below c program?

#include<stdio.h>

int main()
{

     char str[20] = "embeddedkernel";

     str[16] = 'v';

     printf("%s\n", str);
}

9 / 10

What is the o/p of the below c program?

#include<stdio.h>
#include<string.h>
int main()

{

     char *str = "embedded";

     printf("%c %d %x\n", str[strlen(str)], str[strlen(str)], str[strlen(str)]);

}

10 / 10

What is o/p of below program in 64 bit system?

#include<stdio.h>

int main()
{

     char *str1 = "embedded";

     char str2[10] = "kernel";

     printf("%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", sizeof(str1), sizeof(str2), sizeof(str1 + 1), sizeof(str2 + 1), sizeof(*str1), sizeof(*str2), sizeof(str1[2]), sizeof(str2[3]), sizeof(&str1), sizeof(&str2));
}

Your score is

The average score is 55%

0%

Leave a Comment