Strings – Point Out Correct Statements


Warning: Undefined variable $ext in /www/wwwroot/gkfeed.com/public_html/wp-content/plugins/show-hidecollapse-expand/bg_show_hide.php on line 281

Warning: Undefined variable $ext in /www/wwwroot/gkfeed.com/public_html/wp-content/plugins/show-hidecollapse-expand/bg_show_hide.php on line 281

Warning: Undefined variable $ext in /www/wwwroot/gkfeed.com/public_html/wp-content/plugins/show-hidecollapse-expand/bg_show_hide.php on line 281

Warning: Undefined variable $ext in /www/wwwroot/gkfeed.com/public_html/wp-content/plugins/show-hidecollapse-expand/bg_show_hide.php on line 281

1. Which of the following statements are correct about the program below?

Screenshot 1

A. The code converts a string into an integer
B. The code converts lower case character to upper case
C. The code converts upper case character to lower case
D. Error in code

Correct Answer: B. The code converts lower case character to upper case
Advertisement

2. Which of the following statements are correct about the below declarations?
char *p = “Sanjay”;
char a[] = “Sanjay”;
1: There is no difference in the declarations and both serve the same purpose.
2: p is a non-const pointer pointing to a non-const string, whereas a is a const pointer pointing to a non-const pointer.
3: The pointer p can be modified to point to another string, whereas the individual characters within array a can be changed.
4: In both cases, the ‘\0’ will be added at the end of the string “Sanjay”.

A. 1, 2
B. 2, 3, 4
C. 3, 4
D. 2, 3

Correct Answer: B. 2, 3, 4
Advertisement

3. Which of the following statements are correct?

1: A string is a collection of characters terminated by ‘\0‘.
2: The format specifier %s is used to print a string.
3: The length of the string can be obtained by strlen().
4: The pointer CANNOT work on string.

A. 1, 2
B. 1, 2, 3
C. 2, 4
D. 3, 4

Correct Answer: B. 1, 2, 3
Advertisement

4. Which of the following statement is correct?

A. strcmp(s1, s2) returns a number less than 0 if s1>s2
B. strcmp(s1, s2) returns a number greater than 0 if s1<s2
C. strcmp(s1, s2) returns 0 if s1==s2
D. strcmp(s1, s2) returns 1 if s1==s2

Correct Answer: C. strcmp(s1, s2) returns 0 if s1==s2
Advertisement

Warning: Undefined variable $in_same_cat in /www/wwwroot/gkfeed.com/public_html/wp-content/plugins/EXP.GKFEED.COM/function.php on line 27

Warning: Undefined variable $excluded_categories in /www/wwwroot/gkfeed.com/public_html/wp-content/plugins/EXP.GKFEED.COM/function.php on line 27

Leave A Comment?