A) printf("\n");
B) echo "\\n";
C) printf('\n');
D) printf("\\n");
Correct Option - D
Explanation
The statement printf("\\n"); prints '\n' on the screen.
A) strnstr()
B) laststr()
C) strrchr()
D) strstr()
Correct Option - C
Explanation
Declaration: char *strrchr(const char *s, int c);
It scans a string s in the reverse direction, looking for a specific character c.
Example:
#include
#include
int main(void)
{
char text[] = "I learn through IndiaBIX.com";
char *ptr, c = 'i';
ptr = strrchr(text, c);
if (ptr)
printf("The position of '%c' is: %d\n", c, ptr-text);
else
printf("The character was not found\n");
return 0;
}
Output:
The position of 'i' is: 19
A) strchr()
B) strrchr()
C) strstr()
D) strnset()
Correct Option - C
Explanation
The function strstr() Finds the first occurrence of a substring in another string
Declaration: char *strstr(const char *s1, const char *s2);
Return Value:
On success, strstr returns a pointer to the element in s1 where s2 begins (points tos2 in s1).
On error (if s2 does not occur in s1), strstr returns null.
Example:
#include
#include
int main(void)
{
char *str1 = "IndiaBIX", *str2 = "ia", *ptr;
ptr = strstr(str1, str2);
printf("The substring is: %s\n", ptr);
return 0;
}
A) strinit()
B) strnset()
C) strset()
D) strcset()
Correct Option - B
Explanation
char *strnset(char *s, int ch, size_t n); Sets the first n characters of s toch
#include
#include
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz";
char letter = 'x';
printf("string before strnset: %s\n", string);
strnset(string, letter, 13);
printf("string after strnset: %s\n", string);
return 0;
}
If the two strings are identical, then strcmp() function returns
A) -1
B) 1
C) 0
D) Yes
Correct Option - C
Explanation
strcmp(const char *s1, const char*s2);
The strcmp return an int value that is
if s1
if s1 == s2 returns 0
if s1 > s2 returns a value > 0