Question
C++ program. Please help me with these questions, I know the answers to some of them but I need a second thought for verification. Thank
C++ program. Please help me with these questions, I know the answers to some of them but I need a second thought for verification. Thank you in advance.
1)
You have received this warning when compiling a program:
What have you done and how should you fix it?
2)
The code below 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.)
const int SENTINEL = -1; int count = 0; int sum = 0; int num; double average;
cout > num; while (num != SENTINEL) { cout > num; count++; sum += num; }
average = sum/count;
3)
You are writing a program to determine sales commission, where the following commission rates are used:
sales | rate |
3% | |
> 10,000 and | 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.)
4)
An assignment statement
a) changes the value of a variable |
b) can only be used to define a constant |
c) can not be combined with a declaration |
d) is used to determine if an expression is true or false |
5)
int processValue (int val) { if (val > 100) return val - 100; else if (val
int num = 123; int result = processValue (num);
After the call to processValue, what is the value of the variable num?
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