Search
Browse
Create
Log in
Sign up
Log in
Sign up
Upgrade to remove ads
Only $2.99/month
2.14: Arithmetic Operators
STUDY
Flashcards
Learn
Write
Spell
Test
PLAY
Match
Gravity
Key Concepts:
Terms in this set (23)
Assume that an int variable x that has already been declared and initialized .
Write an expression whose value is 1 more than x.
x+1
Write an expression that computes the sum of the two variables verbalScore and mathScore (already declared and assigned values ).
verbalScore+mathScore
Given the variables taxablePurchases and taxFreePurchases (already declared and assigned values ), write an expression corresponding to the total amount purchased.
taxablePurchases+taxFreePurchases
Write an expression that computes the difference of the variables endingTime and startingTime.
endingTime-startingTime
Given the variables fullAdmissionPrice and discountAmount (already declared and assigned values ), write an expression corresponding to the price of a discount admission. (The variable discountAmount holds the actual amount discounted, not a percentage.)
fullAdmissionPrice - discountAmount
given the variable pricePerCase, write an expression corresponding to the price of a dozen cases.
pricePerCase*12
Given the variables costOfBusRental and maxBusRiders, write an expression corresponding to the cost per rider (assuming the bus is full).
costOfBusRental/maxBusRiders
Write an expression that computes the remainder of the variable principal when divided by the variable divisor. (Assume both are type int .)
principal%divisor
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=matricAge+4;
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=cost*3;
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 subtract tax from gross_pay and assign the result to net_pay . (The variables have already been declared and gross_pay and tax have already been initialized .)
net_pay=gross_pay-tax;
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 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;
Write a statement to assign to kilos the value of pounds divided by 2.2. (The variables have already been declared and pounds has already been initialized .)
kilos = pounds/2.2;
Write a statement to find the remainder rem when num is divided by 5. (The variables have already been declared and num has already been initialized .)
rem=num%5;
Assume that an int variable x has already been declared ,.
Write an expression whose value is the last (rightmost) digit of x.
x%10
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is a upper-case letter.
(x>='A' && x<='Z')
Which of the following lines contains a valid, though not necessarily accurate, comment?
int twoPi = 3.14159; /
holds the value of two times pi
/
int twoPi = 2
3.14159; /
holds the value of two times pi //*
int twoPi = 2
3.14159; / /
holds the value of 6 //*
double twoPi = 2
3.14159; /
// holds the value of two time pi */ [comment] //
QUESTION 2: Correct
Which of the following lines does NOT consist of (a) valid, though boastful, comment(s)?
// /
This is a
/ First Rate Program
//*
// This is a //
// First Rate Program //
*//
//
This is a //
// First Rate Program //*//
/
This is a //
// First Rate Program //*//
int twoPi = 3.14159; /
holds the value of two times pi
/
/
This is a //
// First Rate Program //*//
QUESTION 1: Correct
We hope you never have to encounter anything like the following expression in a program, but consider it for a moment and indicate its value: ( /
5 + 3
/ - 9 + 6/
8
//2 ) //
+4
/ -10
3
-7
-6
5
-8
-6
QUESTION 1: Correct
Which comment below is the most helpful?
int volume; // declare an int
int volume; // declare volume
int volume; // declare volume to be an int variable
int volume; // size of trunk in cubic feet
int volume; // size of trunk in cubic feet
THIS SET IS OFTEN IN FOLDERS WITH...
2.6: Integer Data Types
12 terms
Myprogramminglab 2.2, 2.4, 2.5
25 terms
MyProgrammingLab 2.6, 2.7, 2.8, 2.9
34 terms
2.9: Floating-Point Data Types
11 terms
YOU MIGHT ALSO LIKE...
Intro to C Test
50 terms
MyProgrammingLab Visual Basic CH. 3 HW (JAWAD)
91 terms
Chapter 2
65 terms
CMPS 207: chapter 2
123 terms
OTHER SETS BY THIS CREATOR
Stats FINAL EXAM
12 terms
Stats Exam 1
11 terms
Chpt 15
17 terms
Chpt 16
21 terms