Question
1.Evaluate the following: a) 18 - 3 + 6 b) 30 % 12 + 56 - 35 / 5 * 8 c) 14 - 4
1.Evaluate the following:
a) 18 - 3 + 6
b) 30 % 12 + 56 - 35 / 5 * 8
c) 14 - 4 % 11
d) 18.0 + 5.0 * 3.0 / 6.0
2. Given int x = 3; int y = 18; double z = 3.5; and double w = 2.0; evaluate each of the following statements, if possible. If the expression is illegal clarify the reason why.
a) (x + y) % x
b) x % y - w
c) x % (y + z)
d) (y + z) / w
3.Which of the following variable declarations are correct? If a variable declaration is not correct, give the reason and provide the correct variable declaration.
a) double conversion = 2.54;
b) char grade = 'B+';
c) double 28.5 = num;
d) string message = 'First C++ course ';
e) int age = 19 years;
f) float i, y, decimal;
g) double fact 1;
h) string itIsOver = "It is over!"
4.Suppose x, y, z, and w are int variables. What value is assigned to each of these variables after the last statement executes?x = 2; y = 11;z = y - 3 * x;x = z + y;y = x + 5 * z;w = x - y + 2 * z;x = y + w - x;//now x = , y = , z = , w =
5.Suppose x, y, and z are int variables and w and t are double variables. What value is assigned to each of these variables after the last statement executes?x = 22;y = 15;x = x - y / 4 - 2;z = x % 3;w = 27 / 3 + 6.5 * 2;t = x / 4.0 + 15 % 3 - 3.5;
//now x = , y = , z = , w = , t =
6.Write C++ statements that accomplish the following:a) Output the newline character.b) Output the tab character.c) Output double quotation mark.
7.Give meaningful identifiers for the following variables:a) A variable to store the first name of a student.b) A variable to store the discounted price of an item.c) A variable to store the number of juice bottles.d) A variable to store the number of miles traveled.e) A variable to store the highest test score.
8.Write C++ statements to do the following:a) Declare int variable num1 and num2.b) Prompt the user to input two numbers.c) Assign the first input number to num1 and the second input number to num2d) Output num1, num2, and 2 times (num1 minus num2). Your output must identify each variable name followed by its value, then the expression for 2 times (num1 minus num2) followed by its value.
9.Suppose a, b, and c are int variables and it each case the program begins with a = 5, b = 6, and c is undefined. What value is assigned to each variable after each statement executes? If a variable is undefined at a particular statement, report UND(undefined).
Case 1: a = (b++) + 3; //a = , b = , c =
Case 2: c = 2 * a + (++b); //a = , b = , c =
Case 3: b = 2 * (++c) - (a++); //a = , b = , c =
10.What is printed by the following program? Suppose the input is as follows:
Miller34340
#include
using namespace std;
const int PRIME_NUM = 11;
int main () {
const int SECRET = 17;string name;int id;int num;int mysteryNum;cout << "Enter last name: ";cin >> name;cout << endl;cout << "Enter a two digit number: ";cin >> num;cout << endl;id = 100 * num + SECRET;cout << "Enter a positive integer less than 1000: ";cin >> num;cout << endl;mysteryNum = num * PRIME_NUM - 3 * SECRET;cout << "Name: " << name << endl;cout << "Id: " << id << endl;cout << "Mystery number: " << mysteryNum << endl;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started