Answers:
Question 3: option 1 is Correct.
1. void approveFunds( string courseP, string nameP, string & dateP, float costP, bool approvedP )
--> The 3rd and 4th options are wrong because they do not contain the data-type in the header
--> The 2nd option is wrong because it is using the addresses for course, name, and cost but the calling statement in the main function is not passing the addresses for those variables.
-->Option 1 is following the according to the calling statements and has data-types in the header. Hence, it is the correct function.
Question 4: option 2 is Correct.
2. ( !( ( i < 4 || i > 10 ) || ( i * j > 54 ) ) )
--> statement 1 :- i < 4 || i > 10
statement 2 :- i * j > 54 from the question neither should be true which means both statement 1 and statement 2 are false.
Hence, !( i < 4 || i > 10 ) and !( i * j > 54 )
--> !( i < 4 || i > 10 ) && !( i * j > 54 )
--> !( ( i < 4 || i > 10 ) || ( i * j > 54 ) )
when we take both negations ( ! ) common, and (&&) becomes or ( || ).
hence, ( !( ( i < 4 || i > 10 ) || ( i * j > 54 ) ) ).
Question 5: option 1 is Correct.
1. ready = clothing != "jeans" || hat == 'y' && shoes == "bronx";
-->Statement is not wearing jeans or wearing hat and bronx shoes.
--> !(jeans) or (hat and bronx shoes)
--> (clothing != "jeans" ) || ( hat == ''y' && shoes == "bronx" ) since && has higher precedence than ||, we drop the parenthesis.
--> clothing != "jeans" || hat == ''y' && shoes == "bronx"
--> hence, ready = clothing != "jeans" || hat == ''y' && shoes == "bronx" ;
QUESTION 3 2 marks Suppose the following declarations appear in the nai nfunction of a C++...
Which of the options below expresses the logic that a person is ready if they are either not wearing jeans or they are wearing a hat and bronx shoes? 1. ready = clothing != "jeans" || hat == 'y' && shoes == "bronx"; 2. ready = clothing != "jeans" && hat 'y' || shoes "bronx"; 3. ready clothing != "jeans" || hat 'y' || shoes == "bronx"; 4. ready clothing != "jeans" && (hat 'y' && shoes == "bronx"); ==
Suppose the following declarations appear in the mainfunction of a C++ program: string name, course, date; float cost; bool approved; Suppose the following calling statement appears in the mainfunction: approveFunds ("Memory enhancement", "Ellen Subisa", date, 595.00, approved); Which of the options below is a correct function header of the function approve Fundsin the main function? 1. void approveFunds (string course, string name, string & date, float coste, bool & approved) 2. void approveFunds (string & course, string & name, string...
2 COS1511 MAY/JUNE2020 SECTION A 20 MARKS Choose one option for every question. If, for example you choose option 2 as the correct answer for Question 1, and option 4 as the correct answer for Question 2, please answer as follows: 1. 2 2.4 etc. QUESTION 1 2 marks Suppose the following declarations appear in the nai nfunction of a C++ program: string nane, course; char sex; int age; float cost; bool approved; If the following function header is given:...