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

COS132 Chapter 4 Summary

Puntuación
-
Vendido
-
Páginas
9
Subido en
20-04-2022
Escrito en
2021/2022

Summary study book Starting Out with C++ of Tony Gaddis - ISBN: 9789332536661 (Detailed summary)

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

¿Un libro?
Subido en
20 de abril de 2022
Número de páginas
9
Escrito en
2021/2022
Tipo
Resumen

Temas

Vista previa del contenido

COS132 Chapter 4



COS 132
CHAPTER 4 – MAKING DECISIONS
UNIT 4.1- RELATIONAL OPERATORS

Relational operators allow you to compare numeric and char values and determine whether one is greater than, less
than, equal to, or not equal to another.




All of the relational operators are binary, which means they use two operands. Statements such as x > y is called a
relational expression.


THE VALUE OF A RELATIONSHIP
Relational expressions are also known as Boolean expressions, which means their value can be true or false.


WHAT IS TRUTH?
How does a comp store true and false in memory? It converts these two abstract states to numbers, true is represented
by the number 1 and false is represented by the number 0.

UNIT 4.2 – THE IF STATEMENT

The if statement can cause other statements to execute only under certain conditions. The if statement falls under the
category of a decision structure.

An action is only performed if a certain criteria is met/true, the action is conditionally executed bc it is performed only
when a certain condition exists.


BE CAREFUL W SEMICOLONS
If you place a semicolon after the if(expression) statement, the compiler will assume you are placing a null statement
there, the null statement is an empty statement that does nothing, this will terminate the if statement.




1|P a g e

, COS132 Chapter 4

PROGRAMMING STYLE AND THE IF STATEMENT
There are two important style rules:

 The conditionally executed statement should appear on the line after the if statement.
 The conditionally executed statement should be indented one ‘level’ from the if statement


COMPARING FLOATING-POINT NUMBERS
Because of the way floating-point numbers are stored in memory, rounding errors sometimes occur. This is because
some fractional numbers cannot be exactly represented using binary. To prevent round-off errors from causing this type
of problem, you should stick w greater than and less than comparisons w floating-point numbers.


AND NOW, BACK TO TRUTH
0 is still considered false, but values other than 0 are considered true, this means that any value, even a negative
number represents true.

Summary of rules we have looked at so far:

- When a relational expression is true – has the value of 1
- When a relational expression is false – has the value of 0
- Any expression that has the value of 0 is false, and vise versa
- Any expression that has the value of 1 is true, and visa versa

If (value)

Cout << “it is true!”

This if statement tests the contents of a variable, if the variable contains any number other than 0 the message will be
displayed.

UNIT 4.3 – EXPANDING THE IF STATEMENT

The if statement can conditionally execute a block of statements enclosed in brackets.

If (expression)
{
Statements; //block of code
Statements;
}




2|P a g e
$5.73
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


Documento también disponible en un lote

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.
jennamortonx IIE Varsity College
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
18
Miembro desde
3 año
Número de seguidores
1
Documentos
49
Última venta
7 meses hace

4.0

1 reseñas

5
0
4
1
3
0
2
0
1
0

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