100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

COS1511 Assignment 2 Semester 1 2024

Beoordeling
-
Verkocht
-
Pagina's
18
Cijfer
A+
Geüpload op
23-05-2024
Geschreven in
2023/2024

COS1511 Assignment 2 Semester 1 2024 QUESTIONS WITH ANSWERS

Instelling
Vak










Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
23 mei 2024
Aantal pagina's
18
Geschreven in
2023/2024
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

Voorbeeld van de inhoud

COS1511
ASSIGNMENT 2
SEMESTER 1 2024
QUESTIONS WITH COMPLETE ANSWERS




[DATE]

[Company address]

, COS1511 Assignment 2 Semester 1 2024
Question 1
Write function headers for the functions described below:

(i) The function check has two parameters. The first parameter should be an
integer number and thesecond parameter a floating point number. The function
returns no value.

(ii) The function mult has two floating point numbers as parameters and
returns the result ofmultiplying them.

(iii) The function time inputs seconds, minutes and hours and returns them
as parameters to itscalling function.

(iv) The function countChar returns the number of occurrences of a character in a string, both
provided as
parameters.


(i) The function check has two parameters: an integer and a floating point number, and it returns no
value.

def check(integer_param: int, float_param: float) -> None:
pass

(ii) The function mult has two floating point numbers as parameters and returns their product.

def mult(float_param1: float, float_param2: float) -> float:
pass

(iii) The function time takes seconds, minutes, and hours as inputs and returns them to the calling
function.

def time(seconds: int, minutes: int, hours: int) -> (int, int, int):
pass

(iv) The function countChar returns the number of occurrences of a character in a string, both
provided as parameters.

def countChar(input_string: str, character: str) -> int:
pass


Question 2

Find the error(s) in each of the following program segments and explain how
the error(s) can becorrected:

(i) int function1()
{

cout << "Inside function function1 " <<

, endl; int function2()
{

cout << "Inside function function1 " << endl;
}
}

(ii) int sum(int x, int y)
{

int result;
result = x +
y;
}

(iii) int computeProd(int n)
{

if (n == 0)
return 0;

else

}


n * computeProd(n – 1);


(iv) void aFunction(float a)
{


float a;
cout << a << endl;
}


(v) void theProduct()
{

int
a;
int
b;
int
c;
int result;

cout << “Enter three integers “ <<
endl; cin >> a >> b >> c;
result = a * b * c;
cout << “Result is “ << result <<
endl; return result;
}
3

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
smillanih Chamberlian School of Nursing
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
398
Lid sinds
2 jaar
Aantal volgers
327
Documenten
1239
Laatst verkocht
1 maand geleden

3,7

43 beoordelingen

5
23
4
3
3
5
2
5
1
7

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo eenvoudig kan het zijn.”

Alisha Student

Veelgestelde vragen