Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume a program has the following variable definitions int a, b = 2; double c =

ID: 3687543 • Letter: A

Question

Assume a program has the following variable definitions int a, b = 2; double c = 4.3; and the following statement: a = b * c; What value will be stored in a? Assume that qty and sales Reps are both integers. Use a type cast expression to rewrite the following statement so it will no longer perform integer division. unitsEach = qty/salesReps; Rewrite the following variable definition so the variable is a named constant with the value 12. int rate; are deliberately missing. Replace the following statements with a single statement that initializes sum to 0 at the time it is defined. int sum; sum = 0; Is the following code legal? Why or why not? const int DAYS IN WEEK; DAYS_IN_WKEK = 7; are deliberately missing.

Explanation / Answer

11. Answer: 8
   int a,b=2;
   double c=4.3;
   a=b*c;

12. int qty=3,salesReps=5;
double unitsEach=(float)qty/salesReps;

13. const int rate=12;

16. int sum=0;

17.  const DAYS_IN_WEEK; DAYS_IN_WEEK=7; //THIS IS WRONG,

const DAYS_IN_WEEK=7; //IS CORRECT

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote