100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Otro

COS1512 Assignment 1 2024 memo

Puntuación
-
Vendido
-
Páginas
3
Subido en
19-04-2024
Escrito 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

Mostrar más Leer menos
Institución
Grado








Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Libro relacionado

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
19 de abril de 2024
Número de páginas
3
Escrito en
2023/2024
Tipo
Otro
Personaje
Desconocido

Temas

Vista previa del contenido

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
$4.58
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
CrystalIndigo University of South Africa (Unisa)
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
486
Miembro desde
5 año
Número de seguidores
226
Documentos
73
Última venta
1 mes hace
CrystalIndigo Solutions

providing all solutions to all computer science modules

4.1

51 reseñas

5
27
4
13
3
6
2
1
1
4

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes