Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien
logo-home
COS1511 EXAM PACK 2023 $2.50
Ajouter au panier

Examen

COS1511 EXAM PACK 2023

 0 fois vendu
  • Cours
  • Établissement

the document has the latest questions and elaborate answers

Aperçu 4 sur 91  pages

  • 27 mai 2023
  • 91
  • 2022/2023
  • Examen
  • Questions et réponses
avatar-seller
COS1511 EXAM PACK
2023


UPDATED QUESTIONS
AND ELABORATE
ANSWERS


For inquiries and assignment help
Email:

,SECTION A 20 MARKS (10 MULTIPLE CHOICE QUESTIONS, 2 marks each)
Please answer this section on the mark-reading sheet that you received (not in your answer book).
Choose one option for every question.


QUESTION 1

Suppose the following declarations appear in a C++ program:

float amount, forWaiter;
char service;

If the following function header is given:

float tip(float amountP, char serviceP)

which of the options below is a correct calling statement of the functiontip?

1. forWaiter = tip(float amount, char service);
2. tip(amountP, serviceP);
3. forWaiter = tip(123.66, 'A');
4. forWaiter = tip(amountP, serviceP);
5. None of the above options is a correct calling statement.


QUESTION 2

Suppose the following declarations appear in a C++ program:

float afford, amount;
int number;
string name;

If the following function header is given:

void supplyInfo(float affordP, int nrP, string & nameP, float & amountP)

which of the options below is a correct calling statement of the functionsupplyInfo?

1. supplyInfo(800, 4, "Beach Hotel", 789);
2. supplyInfo(800, 4, name, amount);
3. supplyInfo(affordP, nrP, nameP, amountP);
4. supplyInfo(afford, number, "Beach Hotel", 789);
5. None of the above options is a correct calling statement.

, 2 COS111U
May 2009

QUESTION 3

Suppose the following declarations appear in a C++ program:

int age, days;
char grade;
float salary;

Suppose the following calling statement appears in the program:

inputInfo(35, 'B', salary, days);

Which of the options below is a correct function header of the functioninputInfo?

1. void inputInfo(int ageP, char gradeP, float & salaryP, int & daysP)
2. void inputInfo(35, 'B', float salaryP, int daysP)
3. void inputInfo(int & age, char & grade, float & salary, int & days)
4. void inputInfo(35, 'B', salary, days)
5. All of the above options are correct function headers.


Questions 4 and 5 are based on the following C++ program.

#include <iostream>
#include <string>
using namespace std;

int main( )
{
string favour;
int tvHours, favourHours;

cout << "How many hours per week do you watch sport on TV, " << endl
<< "what is your favourite sport, how many hours for that? ";
cin >> tvHours >> favour >> favourHours;

if (tvHours > 10)
if (favour == "soccer")
{
if (favourHours > tvHours / 2)
cout << "Group A" << endl;
}
else
if (favourHours > tvHours / 4)
cout << "Group B" << endl;
else
cout << "Group C" << endl;
else
if (favour != "rugby")
cout << "Group D" << endl;

return 0;

[TURN OVER]

, 3 COS111U
May 2009

}

QUESTION 4

Suppose the program above is executed with the following input:

11 soccer 5

Which of the options below gives the output of the program?

1. Group A
2. Group B
3. Group C
4. Group D
5. No output


QUESTION 5

Suppose the following input is given to the program above:

6 soccer 6

Which of the options below gives the output of the program?

1. Group A
2. Group B
3. Group C
4. Group D
5. No output


QUESTION 6

Suppose in a C++ program values are assigned to astring variable name and to a float variable amount.
Then a while loop is entered. The loop has to be executed as long as
• name is not equal to "NOBODY" and
• amount is not less than 10.00.
Which of the options below gives a correct condition for the loop?

1. ((name != "NOBODY") && (amount >= 10.00))
2. ((name != "NOBODY") || (amount >= 10.00))
3. (!(name == "NOBODY") && (amount < 10.00))
4. (!((name != "NOBODY") && (amount >= 10.00)))
5. None of the options above is a correct condition.


QUESTION 7

Suppose we want to assign the valuetrue to a bool variable success if
• the value of the int variable grade is 10 or higher and

[TURN OVER]

Les avantages d'acheter des résumés chez Stuvia:

Qualité garantie par les avis des clients

Qualité garantie par les avis des clients

Les clients de Stuvia ont évalués plus de 700 000 résumés. C'est comme ça que vous savez que vous achetez les meilleurs documents.

L’achat facile et rapide

L’achat facile et rapide

Vous pouvez payer rapidement avec iDeal, carte de crédit ou Stuvia-crédit pour les résumés. Il n'y a pas d'adhésion nécessaire.

Focus sur l’essentiel

Focus sur l’essentiel

Vos camarades écrivent eux-mêmes les notes d’étude, c’est pourquoi les documents sont toujours fiables et à jour. Cela garantit que vous arrivez rapidement au coeur du matériel.

Foire aux questions

Qu'est-ce que j'obtiens en achetant ce document ?

Vous obtenez un PDF, disponible immédiatement après votre achat. Le document acheté est accessible à tout moment, n'importe où et indéfiniment via votre profil.

Garantie de remboursement : comment ça marche ?

Notre garantie de satisfaction garantit que vous trouverez toujours un document d'étude qui vous convient. Vous remplissez un formulaire et notre équipe du service client s'occupe du reste.

Auprès de qui est-ce que j'achète ce résumé ?

Stuvia est une place de marché. Alors, vous n'achetez donc pas ce document chez nous, mais auprès du vendeur schoolmate. Stuvia facilite les paiements au vendeur.

Est-ce que j'aurai un abonnement?

Non, vous n'achetez ce résumé que pour $2.50. Vous n'êtes lié à rien après votre achat.

Peut-on faire confiance à Stuvia ?

4.6 étoiles sur Google & Trustpilot (+1000 avis)

65040 résumés ont été vendus ces 30 derniers jours

Fondée en 2010, la référence pour acheter des résumés depuis déjà 15 ans

Commencez à vendre!

Récemment vu par vous


$2.50
  • (0)
Ajouter au panier
Ajouté