Question Description
1.
while (i < target)
{
…
i++
}
What data type should i and target be declared as?
2.
An assignment statement
3.
What directive is used to bring the contents of a header file that contains code such as function prototypes into your program before it is compiled? Credit will only be given for indicating the directive, not for any specific use of it.
4.
You have the following code:
string name;
cout << "Enter your name : ";
cin >> name;
If a user enters "Mary Smith" at the prompt for a name, what will name contain after the cin statement?
5.
Indicate if each expression evaluates to true or false.
int a = 10;
int b = 7;
int c = 21;
a < b
! (a < b)
a == b
a < b && c < b
a == b || c > 0
6.
You want to determine if a variable named num contains a value between 1 and 100 (inclusive).
Which expression below should be used?
7.
The statement on line 43 is being executed and the value of x is -1.
Both parts of the expression (x >= 2) and (x <= 10) will be evaluated.
8.
How many times will the statement k = i *j; in the code below be executed?
int i, j, k;
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
k = i *j;
9.
double processValue (int val);
int value = 23;
double result = processValue (value);
For the code shown above, what is the
name of the formal parameter
name of the argument
name of the variable assigned the value returned from processValue
return type of the processValue function
10.
int processValue (int val)
{
if (val > 100)
return val – 100;
else if (val < 0)
return 0;
else
return val;
}
int num = 123;
int result = processValue (num);
After the call to processValue, what is the value of the variable num?
11.
const int MAX = 7;
int main (int argc, char *argv[])
{
int count = 0;
while (count <= MAX)
{
cout << count << endl;
count++;
}
}
The name of the loop control variable for the code above is .
This loop will execute times.
12.
Rewrite the while loop in the code above to be a for loop.
13.
After this statement is executed, what value does answer hold?
double answer = 6/12;
14.
A and B are boolean expressions. Indicate all of the conditions which will cause (A || B) to evaluate to true.
15.
A and B are boolean expressions. Indicate all of the conditions which will cause (A && B) to evaluate to false.
16.
What statement most accurately describes the output of this loop?
for (int i = 2; i < 99; i++)
{
if (i % 2 == 0)
cout << i << " ";
}
17.
The expressions (i % 2 == 0) and (! (i % 2)) will produce equivalent results.
18.
What is the output of the following code?
int count = 1;
while (count <= 10);
{
cout << count << " " << endl;
}
19.
double val;
if (val)
{
…
}
Which of the following values could be assigned to the variable val and result in the body of the if statement being executed?
20.
What keyword in a switch statement covers all possibilities not handled by the cases?
21.
In order to set the field width for output, you use which i/o manipulator?
22.
What data type allows you to directly store the results of comparisons? For example, you want to store the result of the expression x < 100.
23.
You have received this warning when compiling a program:
What have you done and how should you fix it?
24.
const int SENTINEL = -1;
int count = 0;
int sum = 0;
int num;
double average;
cout << "Enter a value: (or -1 to quit): " << endl;
cin >> num;
while (num != SENTINEL)
{
cout << "Enter a value: (or -1 to quit): " << endl;
cin >> num;
count++;
sum += num;
}
average = sum/count;
The code above is part of a working program and has a logic error. Describe it, and indicate how to fix it.
(Remember that only partial code is shown here. The answer is not that this is an incomplete program and that a main function is needed.)
25.
You are writing a program to determine sales commission, where the following commission rates are used:
| sales | rate |
| < 10,000 | 3% |
| > 10,000 and <= 15,000 | 5% |
| > 15,000 | 7% |
Write the constant declarations that will be needed in the code when calculating the commission. You can write these as define directives or as constant variables, but in either case, you must use standard and proper syntax.
(This is not asking to write a program or any code that will use these constants. Show only the constant declarations.)
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.