C-Strings Question and Answer

C-Strings Question and Answer
1. Which of the following function sets first n characters of a string to a given character?
  • strinit()
  • strnset()
  • strset()
  • strcset()
Show Answer
2. If the two strings are identical, then strcmp() function returns
  • -1
  • 1
  • 0
  • Yes
Show Answer
3. How will you print \n on the screen?
  • printf("\n");
  • echo "\\n";
  • printf('\n');
  • printf("\\n");
Show Answer
4. The library function used to find the last occurrence of a character in a string is
  • strnstr()
  • laststr()
  • strrchr()
  • strstr()
Show Answer
5. Which of the following function is used to find the first occurrence of a given string in another string?
  • strchr()
  • strrchr()
  • strstr()
  • strnset()
Show Answer
6. Which of the following function is more appropriate for reading in a multi-word string?
  • printf();
  • scanf();
  • gets();
  • puts();
Show Answer
7. Which of the following function is correct that finds the length of a string?
  • int xstrlen(char *s) { int length=0; while(*s!='\0') { length++; s++; } return (length); }
  • int xstrlen(char s) { int length=0; while(*s!='\0') length++; s++; return (length); }
  • int xstrlen(char *s) { int length=0; while(*s!='\0') length++; return (length); }
  • int xstrlen(char *s) { int length=0; while(*s!='\0') s++; return (length); }
Show Answer
8. The number of bits used in extended ASCII is
  • 7
  • 8
  • 16
  • 32
Show Answer
9. Given a declaration and initialization statement as shown below,
char a [200] = {'0';}
What is the output of the following printf statment ?
  • 48 0 0
  • 44 0 0
  • 46 0
  • 49 0 49 0
Show Answer
10. Given a declaration and initilization as shown below,
char a [6] = {'1', '2', '3', };
What is the output of the following printf statement ?
printf ("%c %c %c %c %c", a[0], a[3], a[4], a[2], a[4], a[1]);
  • 1 2 3 4 5 6 7
  • 1 2 3 4 5
  • 1 3 2
  • 1 2 3 0 0 0
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test