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

COS1512 Assignment 1 2024 memo

Beoordeling
-
Verkocht
-
Pagina's
3
Geüpload op
19-04-2024
Geschreven in
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

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

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

Gekoppeld boek

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
19 april 2024
Aantal pagina's
3
Geschreven in
2023/2024
Type
OVERIG
Persoon
Onbekend

Onderwerpen

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.
CrystalIndigo University of South Africa (Unisa)
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
486
Lid sinds
5 jaar
Aantal volgers
226
Documenten
73
Laatst verkocht
5 maanden geleden
CrystalIndigo Solutions

providing all solutions to all computer science modules

4,1

51 beoordelingen

5
27
4
13
3
6
2
1
1
4

Populaire documenten

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 iDeal of creditcard en download je PDF-document meteen.

Student with book image

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

Alisha Student

Veelgestelde vragen