20
It’s Quiz Time By Bhavya Singhal

Quiz On Strings

Embed Size (px)

Citation preview

Page 1: Quiz On Strings

It’s Quiz Time

By Bhavya Singhal

Page 2: Quiz On Strings

Part-1Find out the

Correct Option

Page 3: Quiz On Strings

1. strinit() 2. strnset()

3. strset() 4. strcset()

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

Page 4: Quiz On Strings

1. “-1” 2. “1”

3. 0 4. Yes

If the two strings are identical, then strcmp() function returns

Page 5: Quiz On Strings

1. printf("\n"); 2. echo "\\n";

3. printf('\n'); 4. printf("\\n");

How will you print \n on the screen?

Page 6: Quiz On Strings

1. strnstr() 2. laststr()

3. strrchr() 4. strstr()

The library function used to find the last occurrence of a character in a string is

Page 7: Quiz On Strings

1. strchr() 2. strrchr()

3. strstr() 4. strnset()

Which of the following function is used to find the first occurrence of a given string in another string?

Page 8: Quiz On Strings

1. printf(); 2. scanf();

3. gets(); 4. puts();

Which of the following function is more appropriate for reading in a multi-word string?

Page 9: Quiz On Strings

2. int xstrlen(char s) { int length=0; while(*s!='\0') length++; s++; return (length); }

3. int xstrlen(char *s) { int length=0; while(*s!='\0') length++; return (length); }

4. int xstrlen(char *s) { int length=0; while(*s!='\0') s++; return (length); }

Which of the following function is correct that finds the length of a string?1. int xstrlen(char *s) { int length=0; while(*s!='\0') { length++; s++; } return (length); }

Page 10: Quiz On Strings

Part-2Tell Yes or No

Page 11: Quiz On Strings

Will the program compile successfully?

#include<stdio.h>int main(){ char a[] = "India"; char *p = "BIX"; a = "BIX"; p = "India"; printf("%s %s\n", a, p); return 0;}

Yes or No

Page 12: Quiz On Strings

For the following statements will arr[3] and ptr[3] fetch the same character?char arr[] = "IndiaBIX";

&char *ptr = "IndiaBIX";

Yes or No

Page 13: Quiz On Strings

Is there any difference between the two statements?char *ch = "IndiaBIX";

&char ch[] = "IndiaBIX";

Yes or No

Page 14: Quiz On Strings

Is there any difference between the two statements?char *ch = "IndiaBIX";

&char ch[] = "IndiaBIX";

Yes or No

Page 15: Quiz On Strings

Part-3Find Out the Output

Page 16: Quiz On Strings

What will be the output of the program ?#include<stdio.h>#include<string.h>

int main(){ char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0;}

1. Hello 2. World

3. Hello World 4. WorldHello

Page 17: Quiz On Strings

What will be the output of the program ?#include<stdio.h>

int main(){ printf(5+"Good Morning\n"); return 0;}

1. Good Morning 2. Good

3. M 4. Morning

Page 18: Quiz On Strings

1. BIX 2. India

3. India Bix 4. India\0Bix

What will be the output of the program ?#include<stdio.h>#include<string.h>

int main(){ char str[] = "India\0\BIX\0"; printf("%s\n", str); return 0;}

Page 19: Quiz On Strings

Acknowledgment 1.http://www.indiabix.com/

2.https://www.tutorialspoint.com//cprogramming/c_strings.htm

Page 20: Quiz On Strings

Thank You