Question
1. (6pts) Assume the following variables are defined: int age; double pay; char section; Write a single cin statement that will read input into each
1. (6pts) Assume the following variables are defined:
int age;
double pay;
char section;
Write a single cin statement that will read input into each of these variables.
2. (8pts) Write C++ program expressions for the following algebraic expression:
a = 10x
z = 3x + 8y + 17k
y = 3
g = +16 / 8
c = 4 / 23
3. (6pts) Rewrite the following variable definition so that the variable is a named constantint
int PayRate;
4. (6pts) Write a multiple assignment statement that can be used instead of the following group of assignment statement:
front = 1;
back = 1;
left = 1;
right = 1;
5. (8pts) In C++, list three type casting methods to convert a character to an integer.
6. (6pts) Which one of following statement is equivalent to num /= a + 5 ?
a. num = num / a + 5;
b. num = num / (a + 5);
c. num = / a + 5;
7. (8pts) List two methods to store a single character being read from the user input, assume variable name is ch.
8. (8pts) What is difference between overflow and underflow? List two potential results when floating-point variables overflow or underflow.
Find the error and modify
(11pts x 4 = 44pts)
1.int number1, number2;
float quotient;
cout << Enter two numbers and I will divide ;
cout << the first by the second for you. << endl;
cin >> number1, number2;
quotient = float
cout << quotient;
2.int number1, number2;
float quotient;
cout << Enter two numbers and I will multiply ;
cout << them by 50 for you. << endl;
cin >> number1, number2;
number1 =* 50;
number2 =* 50;
cout << number1 << << number2;
3.char name; //this line defines a string object
cout << Enter your name: ;
getline >> name;
cout << Hi << name << endl; 4. char ch; int num; cout << Enter a number: ; cin >> num; cout << Enter a letter: ; cin.get();//store user input to ch cout << ch << endl;cout << Hi << name << endl; 4. char ch; int num; cout << Enter a number: ; cin >> num; cout << Enter a letter: ; cin.get();//store user input to ch cout << ch << endl;
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