Question

In: Computer Science

Question 21 You cannot nest structures. Question 21 options: True False Question 22 A structure is...

Question 21

You cannot nest structures.

Question 21 options:

True
False

Question 22

A structure is useful when the program needs to store different values of different types in a single collection.

Question 22 options:

True
False

Question 23

mystring.find(str, x) returns the first position at or beyond position x where the string str is found in mystring. str may be either a string object or a character array

Question 23 options:

True
False

Question 24  

Given the code snippet below, What prints?

string str = "C++ Programming is awesome";

for (int i = 0; i < str.size(); i++)

    {

        if (str[i] == 'a')

        {

            ++ count;

        }

       if (i% 3 == 0)

        {

            ++ count;

        }

    }

    cout << "count is " << " = " << count;

Question 24 options:

11

10

5

2

Question 25

Passing a structure as a constant parameter allows __________________

Question 25 options:

Read-only access

Waste space

Slows down a program

All of the above.

Question 26

  1. Given the code below, which variable is not initialized as a variable of CityInfo

struct CityInfo

{

string cityName;

string state;

long population;

int distance;

};

Question 26 options:

CityInfo location = {"Asheville", "NC", 50000, 28};

CityInfo location = {"Asheville", "NC};

CityInfo location = {"Asheville", "NC", , 28};

CityInfo location = {"Asheville"};

Question 27

If one address comes before another address in memory, the second address is considered the “greater than” the first.

Question 27 options:

True
False

Question 28

The code snippet below converts all upper characters to lower characters

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

    {

        if (isupper(str[i]))

            str[i] = str[i] - 32;

    }

Question 28 options:

True
False

Question 29  

Question 29 options:

Use the correct function to read a line of text which is put in by the user.

string fullName;

cout << "Type your full name: ";

(cin, fullName);  

cout << "Your name is: " << fullName;

Question 30

  1. Given the following code snippet, can you use the if statement to compare the two strings?

string test1 = "This is a string";

    string test2 = "This is a string";

if (strcmp(test1, test2) ){ ….}

Question 30 options:

True
False

Solutions

Expert Solution

Question 21:

Correct Answer: False

Explanation:

A structure is a user-defined data type that is a collection of different data types. The structure data member can be accessed by using the structure variable and dot operator or structure pointer variable and arrow operator.

The given statement is false because a structure can be nested.

Question 22:

Correct Answer: True

Explanation:

A structure is a user-defined data type that is a collection of different data types. The structure data member can be accessed by using the structure variable and dot operator or structure pointer variable and arrow operator.

So, the given statement is true.

Question 23:

Correct Answer: True

Explanation:

The method find() is used to return the first occurrence of the string and it may be string object or character array.

So, the given statement is true.

Question 24:

Correct Answer: 11

Explanation:

The string size is 26.

The first if statement as given below:

if (str[i] == 'a')
{
++count;
}

will inceament the count by 2 because the character 'a' is present two times in the given string.

The second if statement as given below:

if (i% 3 == 0)
{
++count;
}

will increment the count nine times.

The final value of count is 9+2=11.

So, only the first option is correct.


Related Solutions

true or false 21. Product documentation is used before the system is operational. 22. Often the...
true or false 21. Product documentation is used before the system is operational. 22. Often the principal technical communication documents in a project are working papers. 23. Plans, estimates and schedules are documents which report how resources were used during the process of development. 24. The major characteristic of process documentation is that most of it becomes outdated. 25. Test schedules are of little value during software evolution. 26. Product documentation is concerned with describing the design of the software...
Options are not an actual security. True or False? True False
Options are not an actual security. True or False? True False
Which of the following statements are true? Question 1 options: The payment of an annuity cannot...
Which of the following statements are true? Question 1 options: The payment of an annuity cannot vary over time The present value of annuity due is calculated on the same day the first payment occurs In a deferred annuity, interest charges begin to accrue more than one period after the annuity begins. The future value of annuity due is calculated on the same day the last payment occurs The present value of annuity can be calculated as the sum of...
Which of the following statements are true? Question 1 options: The payment of an annuity cannot...
Which of the following statements are true? Question 1 options: The payment of an annuity cannot vary over time The present value of annuity due is calculated on the same day the first payment occurs In a deferred annuity, interest charges begin to accrue more than one period after the annuity begins. The future value of annuity due is calculated on the same day the last payment occurs The present value of annuity can be calculated as the sum of...
Question 1 The name of S3 access point cannot start with a dash. True False Question...
Question 1 The name of S3 access point cannot start with a dash. True False Question 2 Which of the following is an incorrect statement about IAM (Identity and Access Management)? IAM’s goal is to secure the system. IAM grants or denies access to the system. IAM only grants access to the system and does not deny access to the system. IAM is linked to the business policies and procedures. Question 3 AWS services cannot be accessed/managed by using Software...
1. True or false. The mass of a closed system cannot change. 2. True or false....
1. True or false. The mass of a closed system cannot change. 2. True or false. Fahrenheit scale cannot be used in thermodynamics relations. 3. True or false. An extensive property can be a function of time and location. 4. True or false. If a system is at steady state, then the density is uniform throughout the system. 5. True or false. All modes of heat transfer between two bodies must occur when the two bodies are in contact. 6....
21. People with epileptic disorders have intellectual challenges: a)true b)false 22. Epilepsy is a contagious disease:...
21. People with epileptic disorders have intellectual challenges: a)true b)false 22. Epilepsy is a contagious disease: a)true b)false 23. Osteoporosis is a disease of the muscles: a)true B)false 24. Osteoarthritis affects all the body systems: a)true b)false 25. Two types of seizures are partial and generalized: a)true b)false
Question 47 A hinge joint is a multiaxial joint. Question 47 options: True False Question 48...
Question 47 A hinge joint is a multiaxial joint. Question 47 options: True False Question 48 Opening of voltage gated potassium channels results in hyperpolarization. Question 48 options: True False Question 49 Muscles that control precise movements have large motor units. Question 49 options: True False Question 50 Ligaments are a type of epithelial tissue. Question 50 options: True False Question 51 In general, humans have only five senses. Question 51 options: True False Question 55 Hypercalcemia leads to muscle...
Question 47 A hinge joint is a multiaxial joint. Question 47 options: True False Question 48...
Question 47 A hinge joint is a multiaxial joint. Question 47 options: True False Question 48 Opening of voltage gated potassium channels results in hyperpolarization. Question 48 options: True False Question 49 Muscles that control precise movements have large motor units. Question 49 options: True False Question 50 Ligaments are a type of epithelial tissue. Question 50 options: True False Question 51 In general, humans have only five senses. Question 51 options: True False Question 64 Joints with a small...
Question 13 (1 point) Every invertible matrix is diagonalizable. Question 13 options: True False Question 14...
Question 13 (1 point) Every invertible matrix is diagonalizable. Question 13 options: True False Question 14 (1 point) Every diagonalizable matrix is invertible. Question 14 options: True False
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT