CP 120 chp2.1

14 terms by ca30midterm

Create a new folder

Like this study set? Create a free account to save it.

Create a free Quizlet account to save it and study later.

Sign up for an account

Already have a Quizlet account? .

Create an account

Advertisement Upgrade to remove ads


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.


Which of the following is NOT a legal identifier?

7th heaven

*** can not start with a number

Which of the following IS a legal identifier?
"hello world"


Before a variable is used it must be


Declare two integer variables named profitStartOfQuarter and cashFlowEndOfYear .

int profitStartOfQuarter;
int cashFlowEndOfYear;

Write a statement that declares an int variable named count .

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

Declare an integer variable named degreesCelsius .

int count;

int age;
int weight;

int degreesCelsius;

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

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

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

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

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

6. 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.)

1. drivingAge = 17;

2. num =4;

3. higest = num;

4. newRecord = oldRecord;

5. gradAge = matricAge + 4;

6. sum=x+y;

****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;
j= itemp;

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;

*** 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 i;
firstPlaceWinner = secondPlaceWinner;
secondPlaceWinner = i;

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;
int weight;

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;
age= 18;
float weight;

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


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


Please allow access to your computer’s microphone to use Voice Recording.

Having trouble? Click here for help.

We can’t access your microphone!

Click the icon above to update your browser permissions above and try again


Reload the page to try again!


Press Cmd-0 to reset your zoom

Press Ctrl-0 to reset your zoom

It looks like your browser might be zoomed in or out. Your browser needs to be zoomed to a normal size to record audio.

Please upgrade Flash or install Chrome
to use Voice Recording.

For more help, see our troubleshooting page.

Your microphone is muted

For help fixing this issue, see this FAQ.

Star this term

You can study starred terms together

NEW! Voice Recording

Create Set