[CP 2] M4 - Structures

studied byStudied by 0 people
0.0(0)
Get a hint
Hint

char str[80];

1 / 64

flashcard set

Earn XP

Description and Tags

65 Terms

1

char str[80];

Which of the following is correct? Group of answer choices

char str[80];

char (80);

ch str[80];

char 80;

New cards
2

string

It is a sequence of characters

New cards
3

getline()

It is a sequence of characters

New cards
4

isspace()

Returns true provided character expression is a whitespace character, such as the blank or newline character, otherwise, returns false.

New cards
5

cin.getline(str,80);

Which of the following is correct? Group of answer choices

Cin.getline(str,80);

cin.getlines(str,80);

cin.Getline(str,90)

cin.getline(str,80);

New cards
6

! is a punctuation character

What is the output of the given program?

\#include <cctype\>

\#include <iostream\>

using namespace std;

int main()

{

char ch1 \= '!';

if (ispunct(ch1) )

cout << ch1 << " is a punctuation character";

else

cout << ch1 << " is not a punctuation character";

return 0;
New cards
7

toupper()

Converts lowercase letter to uppercase

New cards
8

concatenation

It refers to merging of two strings

New cards
9

isupper()

Returns true provided character expression is an uppercase letter otherwise it returns false

New cards
10

Which of the following operator can be used also in strings?

-

>

@

New cards
11

Hello World

What is the output of the following program?

\#include <iostream\>

\#include <string\>

using namespace std;

int main () {

string str1 \= "Hello ";

string str2 \= "World";

string str3;

str3 \= str1.append(str2);

cout << str3 << endl;

return 0;

}
New cards
12

error

What is the output of the following program?

\#include <iostream\>

\#include <string\>

using namespace std;

int main () {

string str1 \= "Trust";

int len \= str1.size()

cout << len << endl;

return 0;

}
New cards
13

stod

Which of the following function converts a string to double? Group of answer choices

stof

stoll

stod

stoi

New cards
14

#=

Which of the following operators is not a comparison operator? Group of answer choices

>=

==

<=

#=

New cards
15

string

A header file that handles string in C++

New cards
16

char

Strings are accessed by variables of what type?

New cards
17

NOT Equal

What is the output of the following?

\#include <iostream\>

\#include <string\>

using namespace std;

int main () {

string str1 \= "Hello";

string str2 \= "World";

if (str1\==str2)

cout << "Equal";

else

cout << "NOT Equal";

return 0;

}
New cards
18

string

What is the identifier given to string class to declare string objects?

New cards
19

to_string

Which of the following function converts a numerical value to string?

tolower

stoi

toupper

to_string

New cards
20

dot . operator

What operator is used to access the members of a structure?

New cards
21

student.name

Complete the code below:

\#include <iostream\>

\#include <string\>

using namespace std;

struct Person

{

string name;

int age;

};

int main()

{

Person student;

student.name \= "Ronel";

cout << \_________________;

return 0;

}
New cards
22

You need to create an array from a structure named Students, which is correct?

You need to create an array from a structure named Students, which is correct?

Students stud[3];

Students.stud = 3;

Students(3);

students stud -> 3;

New cards
23

yes

Can a structure contain an integer, string and double data type?

New cards
24

struct a_struct {int a;};

Which of the following is a properly defined struct?

struct a_struct {int a;};

struct a_struct int a;

struct {int a;}

struct a_struct {int a;}

New cards
25

;

\What will be used when terminating a structure?

;

;;

}

:

New cards
26

3

How many members are in this structure?

struct Person

{

char name[50];

int age;

double salary;

};

New cards
27

students.age = 22;

Which of the following statements assigns a value to the age member of students? Group of answer choices

stud.age = 25;

age.student = 22;

students.age = 22;

Students.age = 20;

New cards
28

Person var;

Which properly declares a variable of struct Person? Group of answer choices

string Person;

Person var;

struct var;

Person;

New cards
29

s1.salary

Complete the code below:

\#include <iostream\>

\#include <string\>

using namespace std;

struct Person

{

string name;

int age;

double salary;

};



int main()

{

Person s1;

s1.name \= "Ronel";

s1.age \= 35;

\____________ \= 83095.99;

return 0;

}
New cards
30

error

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;

}

New cards
31

Student s1,s2;

Which of the following is the correct declaration of a structure variable?

Student s1:s2;

Student s1,s2;

s1,s2= Student ;

Student (s1,s2);

New cards
32

{}

The function body is written inside ___________

New cards
33

Function

It is a block of code to perform a specific task

New cards
34

3

How many members are in this structure?

struct Person

{

char name[50];

int age;

float salary;

};

New cards
35

structure vARIABLE

A ________________ can be passed to a function in similar way as normal argument.

New cards
36

void funtion

It is simply a function that doesn't need to return anything

New cards
37

doesn't have any parameters

The empty parentheses in a function means that it _______________

New cards
38

overloaded function

Two or more functions having the same name but different argument(s)

New cards
39

argument

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;

}

New cards
40

ctype.h

This header declares a set of functions to classify and transform individual characters.

New cards
41

TEST STRING.

What is the output of the given program?

\#include <iostream\>

\#include <ctype.h\>

using namespace std;

int main ()

{

int i\=0;

char str[]\="Test String.\n";

char c;

while (str[i])

{

c\=str[i];

if (islower(c)) c\=toupper(c);

putchar (c);

i++;

}

return 0;

}
New cards
42

9 1 4

\#include <cctype\>

\#include <iostream\>

\#include <cstring\>

using namespace std;

int main()

{

char str[] \= "hj;pq91js4";



cout << "The digit in the string are:" << endl;

for (int i\=0; i<strlen(str); i++)

{

if (isdigit(str[i]))

cout << str[i] << " ";

}

return 0;

}
New cards
43

tolower()

It returns the lowercase version of a character expression:

New cards
44

strcpy()

Which of the following is a cstring function? Group of answer choices

fabs()

sqrt()

abs()

strcpy()

New cards
45

HELLO WORLD!

What is the output of the given program?

\#include <iostream\>

\#include <ctype.h\>

using namespace std;

int main ()

{

int i\=0;

char str[]\="hello world!\n";

char c;

while (str[i])

{

c\=str[i];

if (islower(c)) c\=toupper(c);

putchar (c);

i++;

}

return 0;

}
New cards
46

strlen()

It returns the length of a string

New cards
47

iscntrl()

Check if a character is a control character

New cards
48

both append and operator +=

Which method do we use to append more than one character at a time?

data

operator +=

both append and operator +=

append

New cards
49

1

What is the output of the given program?

\#include <iostream\>

\#include <string\>

using namespace std;

int main ()

{

string str1 \= "";

cout << str1.empty();

return 0;

}
New cards
50

word is found at index 10

What is the output of the given program?

\#include <iostream\>

\#include <string\>

using namespace std;

int main ()

{

string str1 \= "This is a test";

string str2 \= "test";

cout << "Word is found at index " << str1.find(str2,0);

return 0;

}
New cards
51

H

What is the output of the following program?

\#include <iostream\>

\#include <string\>

using namespace std;

int main () {

string myString \= "Hello";

cout << myString[0];

return 0;

}
New cards
52

Hello World

What is the output of the following program?

\#include <iostream\>

\#include <string\>

using namespace std;

int main () {

string str1 \= "Hello ";

string str2 \= "World";

string str3;

str3 \= str1 + str2;

cout << str3 << endl;

return 0;

}
New cards
53

5

What is the output of the following program?

\#include <iostream\>

\#include <string\>

using namespace std;

int main () {

string str1 \= "Hello";

int len \= str1.size();

cout << len << endl;

return 0;

}
New cards
54

A member

Check the given structure:

struct Person

{

string name;

int age;

float salary;

};

The salary is :

New cards
55

structure

It is a collection of variables of different data types under a single name

New cards
56

Person s1, s2;

If you have a structure named Person, how can you create a structure variable named s1 and s2?

New cards
57

yes

Can you place an array inside a structure?

New cards
58

Person p1;

Check on the given structure:

struct Person

{

char name[50];

int age;

float salary;

};

If you will create an instance of the structure named p1, what would be the command?

New cards
59

Structure variable

\The instance of the structure is known as:

New cards
60

true

A structure variable can be passed to a function in a similar way as a normal argument

New cards
61

Person p,q;

Which of the following is the correct declaration of a structure variable?
Group of answer choices

Person p,q;

Person <p\><q\>;

Person (p,q);

Person "p,q";
New cards
62

60

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 \= 50;

boat2.size +\= boat1.size;

cout<< boat2.size;

return 0;

}
New cards
63

void function

Which of the following functions does not use a return statement? Group of answer choices

int temp (int a)

Void Function

double sales (double x, double y, double x)

int add (int x, int b)

New cards
64

create an array of structure

What does struct Point arr[5]; do?

New cards
65

variable

What is the purpose of s from the following code?

void displayData(Student s)

{

cout << "\nDisplaying Information." << endl;

cout << "Name: " << s.name << endl;

cout <<"Age: " << s.course << endl;

}

New cards

Explore top notes

note Note
studied byStudied by 83 people
... ago
5.0(1)
note Note
studied byStudied by 16332 people
... ago
4.9(156)
note Note
studied byStudied by 131 people
... ago
5.0(1)
note Note
studied byStudied by 13 people
... ago
5.0(1)
note Note
studied byStudied by 208 people
... ago
5.0(1)
note Note
studied byStudied by 35 people
... ago
5.0(1)
note Note
studied byStudied by 81 people
... ago
5.0(1)
note Note
studied byStudied by 41100 people
... ago
4.9(218)

Explore top flashcards

flashcards Flashcard (85)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (21)
studied byStudied by 13 people
... ago
5.0(1)
flashcards Flashcard (98)
studied byStudied by 26 people
... ago
5.0(1)
flashcards Flashcard (100)
studied byStudied by 10 people
... ago
5.0(1)
flashcards Flashcard (61)
studied byStudied by 6 people
... ago
5.0(1)
flashcards Flashcard (63)
studied byStudied by 7 people
... ago
5.0(1)
flashcards Flashcard (67)
studied byStudied by 25 people
... ago
5.0(1)
flashcards Flashcard (31)
studied byStudied by 5 people
... ago
5.0(1)
robot