Question: #include using namespace std; char v_operator; int main() { cout < < Enter your preferred operator < < endl; cin >> v_operator; switch(v_operator)
#include
using namespace std;
char v_operator;
int main()
{
cout << " Enter your preferred operator "
<< endl;
cin >> v_operator;
switch(v_operator)
{
case '+':
cout << " addition " << endl; break;
case '-':
cout << " subtraction " << endl; break;
case '*':
cout << " multiplication " << endl; break;
case '/':
cout << " division " << endl; break;
case '%':
cout << " modulo " << endl; break;
default:
cout << " unknown operator " << endl;
}
return 0;
}
This code right above can be best rewritten using which of the following control structure?
| a. | continue | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| b. | for loop | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c. | while loop | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| d. | if else
What is the equivalent of default when rewriting the code above, question 6, with if else statements?
|
Consider the statement: float a[7] = { 22.2, 44.4, 66.6 }; What is a[[3]
| a. | 66.6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| b. | 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c. | 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| d. | 44.4
Consider the following. What is v[3] after running this program: float& component(float* v, int k) { return v[k-1]; } int main() { float v[4]; for (int k = 1; k <= 4;k++) component(v,k) = 1.0/k; for (int i = 0; i < 4;i++) cout << "v[" << i << "] = " < }
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
