click below
click below
Normal Size Small Size show me how
COMPROG MODULE 3
| Question | Answer |
|---|---|
| Converts lowercase to uppercase. | toupper () |
| Sequence of characters | String |
| What is the output of the program? #include <cstring> #include <iostream> int main () { char str[80]; strcpy (str,"these "); strcat (str,"strings "); strcat (str,"are "); strcat (str,"concatenated."); puts (str); return 0; } | these strings are concatenated. |
| Checks if a character is printable. | isprint() |
| What is the output of the given program? #include <iostream> #include <ctype.h> int main () { int i=0; char str[]="first line "; return 0; } | Blank Screen |
| A string value should always have a _________ enclosed. | Double quotation mark |
| What is the header file for the string class? | #include <string> |
| Which of the following function converts the string to an integer? | stoi |
| It represents a single letter | String |
| A header file that handles string in C++ | string |
| The data elements in the structure are also known as what? | Members |
| What will be used to terminate a structure? | Semicolon (;) |
| If you will create an instance of the structure named p1, what would be the command? | Person p1; |
| Which of the following statements assigns a value to the age member of students? | students.age = 22 |
| What does struct Point arr[5]; do? | Create an array of structure, a structure variable and initialize 5 copied of structure point |
| What is a "structure" in C++? | (All of the above) Also a collection of same data type, and Elements of a structure are called members |
| A ________________ can be passed to a function in similar way as normal argument. | Structure Variable |
| How many members are in this structure? struct Person { char name[50]; int age; double salary; }; | 3 members |
| Which properly declares a variable of struct Person? | Person var; |
| Can a structure contain an integer, string and double data type? | Yes |
| Which of the following is the correct declaration of a structure variable? | Person p,q; |
| What is the output of the program? int main() { structure hotel { int items; char name[10]; }a; strcpy(a.name, "Neji"); a.items=10; cout << a.name; return 0; } | Error (Structure not declared) |
| How many members are in this structure? struct Person { char name[50]; int age; float salary; }; | 3 |
| Which of the following functions does not use a return statement? | Void Function |
| What is the purpose of p from the following code? void displayData(Person p) { cout << "\nDisplaying Information." << endl; cout << "Name: " << p.name << endl; cout <<"Age: " << p.age << endl; cout << "Salary: " << p.salary; } | Argument |
| Which of the following function allows you to read on a character? | get () |
| Which of the following is correct? | cin.getline (str, 80) |
| It converts a numerical value to string? | to_string |
| Which operator is suitable for the concatenation function of a string class? | Operator + |
| What operator is used to access the members of a structure? | Dot (.) Operator |
| It is a collection of variables of different data types under a single name | Structure |
| In the code: Student s; What does the s stand for? | Structure Variable |
| The function body is written inside ___________. | Curly Braces {} |
| Which of the following is correct? | char str[80]; |
| Check if a character is a digit | isdigit() |
| What does concatenation mean? | Merging two strings |
| The append operator is denoted by: | += |
| Which of the following converts string to float? | stof |
| A keyword used to define a structure? | struct |
| If you have a structure named Person, how can you create a structure variable named s1 and s2? | Person s1, s2; |
| Which of the following is the correct declaration of a structure variable? | Student s1, s2; |
| Check if a character is an uppercase letter | isupper() |
| Which of the following is a cstring function? | strcpy() |
| What is the output of the following program? #include <iostream> #include <string> using namespace std; int main () { string str3(5, '#'); cout << str3; return 0;} | ##### |
| Can you place an array inside a structure? | YES |
| What is the output of the following program? #include <iostream> using namespace std; struct ship { int size; } boat1, boat2; int main() { boat1.size = 10; boat2.size = boat1.size; cout<< boat2.size; return 0; } | 10 |
| What is the output of the following program? #include <iostream> #include <string> using namespace std; int main () { string myString = "Hello"; myString[0] = 'J'; cout << myString; return 0; } | Jello |
| This header declares a set of functions to classify and transform individual characters. | ctype.h |
| Which of the following is a cstring function? | strcmp () |
| It returns the length of a string | strlen() |
| Which of the following functions gets the length of a string? | both length and size |
| Which method do we use to append more than one character at a time? | both append and operator += |
| Which of the following operators is not a comparison operator? | #= |
| A structure variable can be passed to a function in a similar way as a normal argument [T/F] | True |
| It is a block of code to perform a specific task | Function |
| Which of the following accesses a variable in structure b? | b.var; |
| The empty parentheses in a function means that it _____________. | Doesn’t have parameters |
| Which of the following compares two string values? | strcmp () |
| If two strings are identical, then the strcmp() function returns: | 0 |
| Which of the following function converts a string to double? | stod |
| #include <string> #include <iostream> using namespace std; int main() { string x = "Bad "; cout << x.append("Liar"); return 0; } | Bad Liar |
| Strings are accessed by variables of what type? | char |
| It is simply a function that doesn't need to return anything | Void Function |