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
Autre

COS1512 Assignment 1 2024 memo

Note
-
Vendu
-
Pages
3
Publié le
19-04-2024
Écrit en
2023/2024

COS Assignment 1 memo NOTE: Questions maybe different Question 1 The assert statement 1. tests conditions or assumptions that should not occur in a program to prevent runtime errors 2. will display an error message when the condition in the statement is not true and abort the program. 3. All of the other options are valid. 4. can be turned on and off in a program Question 2 Base your answer to this question on the highlighted directives at the beginning of the program. The program below will abort and display that the assertion has failed #define NDEBUG #include cassert int main() { int x = 7; /* Some big code in between and let's say x is accidentally changed to 9 */ x = 9; // Programmer assumes x to be 7 in rest of the code assert(x==7); /* Rest of the code */ return 0; } 1. True 2. False Question 3 To ensure that a test score score is valid, i.e. = 0 and = 100, we can use the following statement 1. assert(!(0 = score || score = 100)); 2. assert(score = 0 && score = 100); 3. assert(score = 0 || score = 100); 4. assert(!(0 = score && score = 100)); Question 4 A function returning a value must specify, in its header line, the ____ of the value that will be returned. 1. size 2. address 3. use 4. data type Question 5 An integrated development environment (IDE) 1. translates programming language instructions one line at a time into machine language 2. turns source code into an object program 3. is used to edit, preprocess, compile, link, load and execute programs written in a high-level language like C++ 4. checks your program for syntax errors Question 6 The compiler decides which definition of an overloaded function to execute based on the number of parameters or the types of parameters. 1. True 2. False Question 7 What is the output of the following program? #include iostream using namespace std; int operate (int a, int b) { return (a * b); } float operate (float a, float b) { return (a / b); } int main() { int x = 5, y = 2; float n = 5.0, m = 2.0; cout operate(x, y) "t"; cout operate (n, m); return 0; } 1. 10.0 5 2. 10 2.5 3. 10.0 5.0 4. 5.0 2.5 Question 8 Consider the following function headers: double calcVolume (double width, double height, double length); double calcVolume (double radius); double calcVolume (double radius, double height); The function call int volume = calcVolume(7.3, 5.1); 1. will execute this function double calcVolume (double width, double height, double length); 2. will execute this function double calcVolume (double radius); 3. will execute this function double calcVolume (double radius, double height); 4. will give a compiler error Question 9 Errors that can only be detected when a program is run, is called run-time errors. Question 10 When designing a program, the result of the problem-solving phase should be a Algorithm

Montrer plus Lire moins
Établissement
Cours

Aperçu du contenu

COS1512 2024 Assignment 1 memo

Crystal Indigo!
Crystal Indigo!
Providing all solutions you need anytime
+27 76 626 8187




NOTE: Questions maybe different

Question 1 The assert statement
1. tests conditions or assumptions that should not occur in a program to prevent runtime errors
2. will display an error message when the condition in the statement is not true and abort the
program.
3. All of the other options are valid.
4. can be turned on and off in a program


Question 2 Base your answer to this question on the highlighted
directives at the beginning of the program.
The program below will abort and display that the assertion has failed
#define NDEBUG
#include <cassert >

int main()
{
int x = 7;
/* Some big code in between and let's say x
is accidentally changed to 9 */
x = 9;
// Programmer assumes x to be 7 in rest of the code
assert(x==7);
/* Rest of the code */
return 0;
}

1. True
2. False

Livre connecté

École, étude et sujet

Établissement
Cours

Infos sur le Document

Publié le
19 avril 2024
Nombre de pages
3
Écrit en
2023/2024
Type
AUTRE
Personne
Inconnu

Sujets

3,93 €
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.
CrystalIndigo University of South Africa (Unisa)
S'abonner Vous devez être connecté afin de pouvoir suivre les étudiants ou les formations
Vendu
486
Membre depuis
5 année
Nombre de followers
226
Documents
73
Dernière vente
5 mois de cela
CrystalIndigo Solutions

providing all solutions to all computer science modules

4,1

51 revues

5
27
4
13
3
6
2
1
1
4

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