Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien 4,6 TrustPilot
logo-home
Examen

COS1511 Assignment 2 Semester 1 2024

Note
-
Vendu
-
Pages
18
Grade
A+
Publié le
23-05-2024
Écrit en
2023/2024

COS1511 Assignment 2 Semester 1 2024

Établissement
Cours










Oups ! Impossible de charger votre document. Réessayez ou contactez le support.

École, étude et sujet

Établissement
Cours

Infos sur le Document

Publié le
23 mai 2024
Nombre de pages
18
Écrit en
2023/2024
Type
Examen
Contient
Questions et réponses

Sujets

Aperçu du contenu

[Date]




COS1511 Assignment
2 Semester 1 2024
QUESTIONS AND ANSWERS

, 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
€2,62
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
En ligne et en PDF
Tu n'es attaché à rien

Faites connaissance avec le vendeur

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
brighttutor10 Central Michigan University
S'abonner Vous devez être connecté afin de suivre les étudiants ou les cours
Vendu
85
Membre depuis
2 année
Nombre de followers
47
Documents
987
Dernière vente
2 mois de cela

4,1

8 revues

5
4
4
1
3
3
2
0
1
0

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions