Quiz On Strings
-
Upload
bhavya-singhal -
Category
Education
-
view
44 -
download
0
Transcript of Quiz On Strings
![Page 1: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/1.jpg)
It’s Quiz Time
By Bhavya Singhal
![Page 2: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/2.jpg)
Part-1Find out the
Correct Option
![Page 3: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/3.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/4.jpg)
1. “-1” 2. “1”
3. 0 4. Yes
If the two strings are identical, then strcmp() function returns
![Page 5: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/5.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/6.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/7.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/8.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/9.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/10.jpg)
Part-2Tell Yes or No
![Page 11: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/11.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/12.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/13.jpg)
Is there any difference between the two statements?char *ch = "IndiaBIX";
&char ch[] = "IndiaBIX";
Yes or No
![Page 14: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/14.jpg)
Is there any difference between the two statements?char *ch = "IndiaBIX";
&char ch[] = "IndiaBIX";
Yes or No
![Page 15: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/15.jpg)
Part-3Find Out the Output
![Page 16: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/16.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/17.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/18.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/19.jpg)
Acknowledgment 1.http://www.indiabix.com/
2.https://www.tutorialspoint.com//cprogramming/c_strings.htm
![Page 20: Quiz On Strings](https://reader036.fdocuments.net/reader036/viewer/2022062412/58f2d0261a28ab50638b4575/html5/thumbnails/20.jpg)
Thank You