(2024/250 WGU C960 Discrete Math 2, Questions and answers, 100% Accurate, VERIFIED.
WGU C960 Discrete Math 2, Questions and answers, 100% Accurate, VERIFIED. 1.4.3: If-else-statement 1) What is the value of abs after the following lines of code are run? x := 2 If ( x > 0 ) abs := x Else abs := -x End-if 2 The condition ( x > 0 ) evaluates to true because the value of x is 2. The line abs := x is executed and the line abs := -x is skipped. Therefore the final value of abs is 2. 1.4.3: If-else-statement 2) What is the value of abs after the following lines of code are run? x := -2 If ( x > 0 ) abs := x Else abs := -x End-if 2 The condition ( x > 0 ) evaluates to false because the value of x is -2. The line abs := x is skipped and the line abs := -x is executed. Therefore the final value of abs is -x, which is -(-2) = 2. 1.5.2: For-loops Consider the following pseudocode fragment: sum := 0 For i = 2 to 5 sum := sum + i
Escuela, estudio y materia
- Institución
- Western Governors University
- Grado
- WGU C960
Información del documento
- Subido en
- 24 de octubre de 2023
- Número de páginas
- 153
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas
Temas
-
wgu c960 discrete math 2 questions and answers
Documento también disponible en un lote