Question: QUESTION 2 4 MARKS In Questions 2.1 and 2.2 you have to write down what the purpose of the segment of code is. Look




QUESTION 2 4 MARKS In Questions 2.1 and 2.2 you have to write down what the purpose of the segment of code is. Look at the following example before answering the questions: 2.1 int a,b,c cin >> >> >> cout < < c + b + a: The purpose of the above code segment is to input three integer values and display their sum Now answer questions 2.1 and 2.2 below: Assume that and have been declared as integers. Explain in words what the purpose of the following segment of code is: (2) int 0 int n = 0; while in sales; while (sales > 0.0) T 8 9 ). 10 // endwhile Commission sales 0.1; cout < < commission < < endl; 89% 9 MARKS Assume the following: Da declaration of a global constant: const int NUM DAYS = 365; two declaration statements in the main function: int crates (NUM_DAYS]; int average: (2) (3) In this question you have to write a complete function. The Fruit Packers keep record of the number of crates of fruit that are packed for each day for a whole year (365 days). These 365 values are stored in an intarray called crates. You have to write a function, called calcAverageto determine the average number of crates packed per day for the year. 6 MARKS // number of days per year // array of days // the average number of crates [TURN OVER] INP1501 Oct/Nov 2023 8.1 8.2 int average: values have been assigned already to all the elements of the array the function is called in the main function as follows: average calcAverage (crates); Write down ONLY the complete function calcAverage. QUESTION 8 Write a function header for the function checkthat has two parameters. The first parameter should be an integer value and the second parameter a floating point value. The function returns no value. (1) // the average number of crates 8.6 [TURN OVER] INP1501 Oct/Nov 2023 Write a function header for the function mult that has two floating point numbers as parameters and returns the result of multiplying them. 8.3 Write a function header for the function time that inputs seconds, minutes and hours and returns them as parameters to its calling function. (1) 8 MARKS 8.4 Write a function header for the function countlet sthat returns the number of occurrences of a character in a string, both provided as parameters. (1) QUESTION 9 8.5 Suppose the following declarations appear in the mainfunction of a C++ program: int numbers float cost, markup, discount, Also, suppose the following calling statement appears in the mainfunction amount - caleFinal (67.50, markup, discount, 532 Write the correct function header of the function calcFinal? Suppose the following declarations appear in the mainfunction of a C++ program string dayOfWeek; int product Code, number; float discount 11 If the following function header is given void caleDiscount (float & discount, ist product Code?. int number?, string dayofWeek?); give the correct calling statement of the function calebiscount in the mainfunction (2) (2) [TURN OVER] INP1501 Oct/Nov2023 & MARKS Bookworm bookstores announced a competition running over four weeks for their three branches The branch with the highest sales per week will receive a surprise for that week. You as a asted to write a program to lear ecord of the number of books programmat Chrome. 6.1 INP1501 Oct-Nov 20... 4 Assume that countTwo, count Four and count More have been initialised already and that a value has been input and validated for nrWheels. QUESTION 6 6.2 6.3 6.4 1 2 4 Write a for-statement to display the numbers 1 through 10 on the screen. Write a while-statement to display the numbers 1 through 10 on the screen. The code below should display the numbers 1, 2, 3and on the screen. However, the code is not working correctly. Correct the errors in the code. (2) 1 2 4 5 6 7 int num = 1; while (num > sales; while (sales > 0.0) T 8 9 ). 10 // endwhile Commission sales 0.1; cout < < commission < < endl; 89% 9 MARKS Assume the following: Da declaration of a global constant: const int NUM DAYS = 365; two declaration statements in the main function: int crates (NUM_DAYS]; int average: (2) (3) In this question you have to write a complete function. The Fruit Packers keep record of the number of crates of fruit that are packed for each day for a whole year (365 days). These 365 values are stored in an intarray called crates. You have to write a function, called calcAverageto determine the average number of crates packed per day for the year. 6 MARKS // number of days per year // array of days // the average number of crates [TURN OVER] INP1501 Oct/Nov 2023
Step by Step Solution
3.41 Rating (154 Votes )
There are 3 Steps involved in it
Here is the role of computational fluid dynamics CFD in process modeling Process Optimization via Nu... View full answer
Get step-by-step solutions from verified subject matter experts
