• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 33 páginas
Examen

ENGR 103 Midterm Exam With Complete Solution

Document preview thumbnail
Vista previa 4 fuera de 33 páginas

ENGR 103 Midterm Exam With Complete Solution...

Vista previa del contenido

ENGR 103 Midterm Exam With
Complete Solution

(3 pts) What is the output of the following code, and why?

int a = 1, b = 1, c = 1;

if (a == b || c++){

int a = 20;

b = b + a;

}

cout << a << " " << b << " " << c << " " << endl; - ANSWER 1 21 1 Hint:
scope, short-circuiting

Algorithm - ANSWER A methodical, logical rule or procedure that guarantees
solving a particular problem.

Computation - ANSWER Operates to give an output that follows a definite
set of rules.

Signed vs Unsigned - ANSWER Signed can be negative and positive.
Unsigned cannot be negative.

Variable - ANSWER Store value that can change depending on the condition

Operand vs Operator - ANSWER The operator indicates what action or
operation to perform. Operands suggest what items to apply the action.

rvalue to. lvalue * pre and post-increment/decrement - ANSWER lvalue is

,object and rvalue is value.

% - ANSWER operator use to get remain

What is the value of my_value in the following exmaple? int my_value; -
ANSWER any number

What are two ways to create a constant in C++ Wht are the pros and cons? -
ANSWER const int my_constant= 42;

#define MY_CONSTANT 42

Given N bytes, what is the maximum and minumum represntable njmber of
signed and unsigned? - ANSWER INT_MAX

INT_MIN

max = 65535

min -32768

Describe the diffence between syntax vs semantics - ANSWER Syntax is
concerned with the form of the code, while Semantics is concerned with its
meaning and behavior. Both are imporatn for writting correct and effective
C++ code.

List and label the relational and logical operators, and what is the difference
between them? - ANSWER Relational operators are used to compare two
value and determine the relationship between them. They return Boolean
value of either 'true' or 'false'

Like

< (less than)

,> (greater than)

<= (less than or equal to)

>= (greater than or equal to)

== (equal to)

!= (not equal to)

Logical operators are used to perform Boolean operations on Boolean values.

&& (logical AND)

|| (logical OR)

! (logical NOT)

Give examples of when you use logical and relational operators in your every
life - ANSWER It is sunny outside and I want to go to the beach.

What is short circuiting and when is it useful? - ANSWER %% which stand for
"AND" and || Which stand for "OR"

When would you use an if versus switch - ANSWER If statement is when you
want to test one or more conditions and execute diferencet staments based
on the results of the test.

Swtich in other hand is you when you want to choose betwen sveral
alternative actions besed on the vlaue of a single expression.

What are the limitations with a switch? - ANSWER Limited data types like int
char short or long

No expression

, No range

No floating

What if you are missing a break in a switch? - ANSWER It will keep fall
through until the exectons will continue from oen case to. the next,
executing the coee in each case until it encounters a 'break' statement.

Can you nest switches and if/else? If so, how? - ANSWER Yes

int value = 1;

if (value > 0) {

switch (value) {

case 1:

// code for case 1

break;

case 2:

// code for case 2

break;

default:

// code for any other value

break;

}

} else {

Información del documento

Subido en
5 de octubre de 2024
Número de páginas
33
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$11.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

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.
Belina
4.2
(19)
Vendido
77
Seguidores
23
Artículos
1439
Última venta
2 meses hace




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