100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4,6 TrustPilot
logo-home
Other

COS1512 Assignment 1 2024 memo

Rating
-
Sold
-
Pages
3
Uploaded on
19-04-2024
Written 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

Show more Read less

Content preview

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

Document information

Uploaded on
April 19, 2024
Number of pages
3
Written in
2023/2024
Type
OTHER
Person
Unknown

Subjects

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
CrystalIndigo University of South Africa (Unisa)
View profile
Follow You need to be logged in order to follow users or courses
Sold
486
Member since
5 year
Number of followers
226
Documents
73
Last sold
5 months ago
CrystalIndigo Solutions

providing all solutions to all computer science modules

4,1

51 reviews

5
27
4
13
3
6
2
1
1
4

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions