MyProgrammingLab Ch. 2.1

Your page rank:

Total word count: 748
Pages: 3

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

A location in memory used for storing data and given a name in a computer program is called a _______ because the data in the location can be changed.

variable

An identifier that cannot be used as a variable name is a _______ word.

reserved

Which of the following is NOT a legal identifier?

7thheaven

Which of the following IS a legal identifier?

_________________

Which of the following is NOT a C++ keyword?

main

Before a variable is used it must be

declared

Declare two integeer variables name profitStartOfQuarter and cashFlowEndOfYear.

int profitStartOfQuarter, cashFlowEndOfYear;

Write a statement that declares an int variable named count.

int count; cout << count;

Declare an integer variable named degreesCelsius.

int degreesCelsius;

Write a declaration for two integer variables, age and weight.

int age, weight;

Given an integer variable drivingAge that has already been declared , write a statement that assigns the value 17 to drivingAge.

drivingAge = 17;

Write a statement to set the value of num to 4 (num is a variable that has already been declared ).

num = 4;

Given two integer variables num and highest, write a statement that gives highest the same value that num has.

highest = num;

Given two integer variables oldRecord and newRecord, write a statement that gives newRecord the same value that oldRecord has.

newRecord = oldRecord;

Given two integer variables matricAge and gradAge, write a statement that gives gradAge a value that is 4 more than the value of matricAge.

gradAge = 4 + matricAge;

Write a statement to set the value of ans equal to the value of num plus 5. (These variables have already been declared and num has already been initialized .)

ans = num + 5;

Write a statement to set the value of price equal to three times the value of cost. (The variables have already been declared and cost has already been initialized .)

price = 3 * cost;

Write a statement to set the value of area to the value of length times the value of width. (The variables have already been declared and length and width have already been initialized .)

area = length * width;

Write a statement to multiply diameter by 3.14159 and assign the result to circumference. (The variables have already been declared and diameter has already been initialized .)

circumference = diameter * 3.14159;

Write a statement to add the values of x and y together, storing the result in sum . (The variables have already been declared and x and y have already been initialized .)

sum = x + y;

Write a statement to assign to weight_in_pounds the value of weight_in_kilos times 2.2. (The variables have already been declared and weight_in_kilos has already been initialized .)

weight_in_pounds = weight_in_kilos * 2.2;

Given two int variables , i and j, which have been declared and initialized , and two other int variables , itemp and jtemp, which have been declared , write some code that swaps the values in i and j by copying their values to itemp and jtemp, respectively, and then copying itemp and jtemp to j and i, respectively.

jtemp = j; itemp = i; j = itemp; i = jtemp;

Given three already declared int variables , i, j, and temp, write some code that swaps the values in i and j. Use temp to hold the value of i and then assign j’s value to i. The original value of i, which was saved in temp, can now be assigned to j.

temp = i; i = j; j = temp;

Given two int variables , firstPlaceWinner and secondPlaceWinner, write some code that swaps their values .
Declare any additional variables as necessary, but do not redeclare firstPlaceWinner and secondPlaceWinner.

int temp; temp = firstPlaceWinner; firstPlaceWinner = secondPlaceWinner; secondPlaceWinner = temp;

Write a statement that declares and initializes two integer variables . Call the first one age and initialize it to 15, and call the second one weight and initialize it to 90.

int age = 15, weight = 90;

Declare an integer variable cardsInHand and initialize it to 13.

int cardsInHand = 13;

Declare a floating point variable named distance.

float distance;

Write a statement that declares a double variable named dosage.

double dosage;

Write declaration statements to declare and initialize two variables : one is an integer variable named age, initialized to 18, and the other variable , named weight, is initialized to 114.5.

int age = 18; double weight = 114.5;

Of the following variable names, which is the best one for keeping track of whether a patient has a fever or not?

hasFever

Of the following variable names, which is the best one for keeping track of whether an integer might be prime or not?

mightBePrime

Which is the best identifier for a variable to represent the amount of money your boss pays you each month?

monthlyPay

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending