Search Header Logo
C++ Strings

C++ Strings

Assessment

Presentation

Computers

University

Medium

Created by

Joshua Martinez

Used 1+ times

FREE Resource

39 Slides • 15 Questions

1

media

2

Multiple Choice

How many types of strings do we have in C++?

1

1

2

2

3

3

4

4

3

Multiple Choice

Which is TRUE about strings?

1

It is enclosed in single quotes

2

It has a fixed length

3

It is a collection of strings

4

It is a collection of characters

4

media

5

media

6

media

7

media

8

media

9

media

10

media

11

media

12

media

13

media

14

media

15

media

16

media

17

media

18

media

19

media

20

media

21

media

22

media

23

media

24

media

25

media

​Quick Quiz

​Lecture on Strings

26

Multiple Choice

Which of the following is closest equivalent to the code below?

char str[] = "hello";

1

char str[10] = "hello";

2

char str[10] = {'h','e','l','l','o',\0'};

3

char str[10] = {'h','e','l','l','o'};

4

char str[6] = "hello";

27

Multiple Choice

What C String will be stored in the letterString after the following code is run?

char letterString[20] = "DoBeDo";

strcat(letterString, " to you");

1

DoBeDo

2

to you

3

DoBeDotoyou

4

DoBeDo to you

28

Multiple Choice

Question image

What is the output of the following code?

1

Hello

2

and Good bye

3

Hello and Good Bye

4

Compile Error

29

Multiple Choice

Question image

What should be done to make this code work?

1

Line 9: strcat(string_var[], " and Good Bye"

2

Line 10: cout << sting_var[];

3

Line 8: char string_var[20] = "Hello";

4

Line 9: string_var += " and Good Bye";

30

Multiple Choice

What is the maximum length of a string that can be placed in the c-string declared below?

char text[6];

1

4

2

5

3

6

4

7

31

Multiple Choice

What code will copy the string "hello" to the c-string declaration below?

char text[6];

1

text = "hello";

2

text[] = "hello";

3

strcpy(text,"hello");

4

strcat(text,"hello");

32

Fill in the Blank

How many characters are there in 'n'?

Note: The answer must be numeric.

33

Fill in the Blank

How many characters are there in '\n'?

Note: The answer must be numeric.

34

Fill in the Blank

How many characters are there in "Josh"?

Note: The answer must be numeric.

35

Multiple Choice

Are the codes below equivalent?

char letters[] = "ABC";

char letters[] = {'A','B','C'};

1

Yes

2

No

36

Multiple Choice

Why are the codes below NOT equivalent?

char letters[] = "ABC";

char letters[] = {'A','B','C'};

1

The first is a c-string and the second is a string

2

The first is a cstring and the second is a character array

3

The first is a string and the second is a c-string

4

The first is a character array and the second is a c-string

37

media

38

media

39

media

40

media

41

media

42

media

43

media

44

media

45

media

46

media

47

media

48

media

49

media

50

media

51

media

52

media

53

Multiple Choice

Question image

What is the output of the code given the input "Hello friend!"

1

Equal

2

Not Equal

54

Multiple Choice

Question image

What is the output of the code snippet?

1

Hello Hello

2

Jello Jello

3

Hello Jello

4

Jello Hello

media

Show answer

Auto Play

Slide 1 / 54

SLIDE