Arduino Multiple Choice Questions on “String Manipulation”.
1. What is the special escape sequence for newline in C++?
a) ‘b’
b) ‘m’
c) ‘n’
d) ‘\’
Answer: c
Calrification: The newline character is used for shifting the cursor to the next line for any output to the monitor. It is mostly used for formatting output. During execution this escape sequence is converted to the OS Specific newline representation.
2. What is the minimum number of arguments that the strcpy() function accept?
a) 4
b) 3
c) 2
d) 1
Answer: c
Calrification: The strcpy() function is used to copy the contents from one String variable to another. Hence it requires a minimum of two arguments that include the source variable (The variable from whose contents need to be copied from) and the destination variable (The variable to which the contents are to be copied to).
3. What is the function of the strcmp() function?
a) To compare two strings
b) To compile two strings
c) To concatenate two strings
d) To converge two strings
Answer: a
Calrification: The strcmp() function takes in two arguments to work and it’s job is to compare two strings. it returns 0 if the first and second strings are the same, returns a number greater than 0 if the first string is greater than the second one and vice versa.
4. Which of the following escape sequences placed at the end of a string makes the string a Null Terminated String?
a) ‘p’
b) ‘u’
c) ‘ ’
d) ‘1’
Answer: c
Calrification: The ‘ ’ when placed at the end of a string makes it a null terminated string which is simply a single dimensional array of characters that are trailed by the ‘ ’ escape sequence. It is also called the ASCII NUL character.
5. What is the return type of the front() function? 6. How many arguments does the back() function take? 7. How many arguments does the at() function take? 8. Which of these functions are used to partially or fully substitute a string?
a) char
b) int
c) long
d) short
Answer: a
Calrification: The front() function returns a character from the string given as input. It takes in no arguments. It returns the first character that is present in the string. It can be used as “cout<
a) 0
b) 1
c) 2
d) 3
Answer: a
Calrification: The back() function returns a character from the string given as input. It takes in no arguments. It returns the last character that is present in the string. It can be used as “cout<
a) 0
b) 1
c) 2
d) 3
Answer: b
Calrification: The at() function returns a character from the string given as input. It takes 1 argument. It returns the character that is present in the string as specified by the argument. It can be used as “cout<
a) replace()
b) size()
c) subs()
d) substring()
