• Verkeerd document? Gratis ruilen
  • Geschreven door studenten die geslaagd zijn
  • Direct beschikbaar na je betaling
  • Online lezen of als PDF
Verkopen
Kies je studieland
Kies je taal
Document preview thumbnail
Voorbeeld 2 van de 9 pagina's
Samenvatting

COS132 Chapter 3 summary

Document preview thumbnail
Voorbeeld 2 van de 9 pagina's

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

Voorbeeld van de inhoud

COS132 Chapter 3



COS 132
CHAPTER 3 – EXPRESSIONS AND INTERACTIVITY
UNIT 3.1- THE CIN OBJECT


The cin object can be used to read data typed at the keyboard.

cout << “What is the length of the rectange? ”; // This is know as a prompt

cin >> length;

The “>>” symbol is the stream extraction operator, it gets the characters from the stream object onits left and stores
them in the variable whose name appears on the right. The << and >> operators point in the direction that the data is
flowing.

The cin object causes a program to wait until data is typed at the keyboard and the enter key is pressed. Cin
automatically converts the inputted data to the data type of the variable.

NB – you must include <iostream> header file in any program that uses cin.


ENTERING MULTIPLE VALUES
cin >> length >> width;

The enter key is pressed after the last number is entered. Cin will also read multiple values of different data types.




When the user types a value, those first values are stored in an area memory known as the keyboard buffer.

UNIT 3.2 – MATHEMATICAL EXPRESSIONS

C++ allows you to construct complex mathematical expressions using multiple operators and grouping symbols.

Result = 4;

Result = ;

Result = a + b + c;

1|P a g e

, COS132 Chapter 3



OPERATOR PRECEDENCE
Highest - (unary negation)

* / %

Lowest + -


ASSOCIATIVITY
An operators associativity is either to the left or the right, if two operators sharing an operand have the same
precedence, they work according to their associativity.

- (unary negation) Right to left

* / % Left to right

+ - Left to right


GROUPING WITH PARENTHESES
This forces some operations to be performed before others.


NO EXPONENTS PLEASE!
Raising a number to a power requires the use of a library function, called pow.

area = pow(4.0, 2.0);

This statement contains a call to the pow function, the numbers inside the brackets are called arguments (= data being
sent to the function). The pow function raises the first argument to the power of the second argument. The result is
returned from the function and used in the statement where the function call appears.

The program must include <cmath> header file, and the arguments that you pass to the pow function should be doubles.
The variable used to store pow’s return value should also be double.

UNIT 3.3 – WHEN YOU MIX APPLES AND ORANGES: TYPE CONVERSION

When an operator’s operands are of different data types, C++ will automatically convert them to the same data type(this
is known as type coercion). When a value is converted to a higher data type it is promoted, and when it is converted to a
lower data type, it is demoted.




2|P a g e

Gekoppeld boek
 image
Tony Gaddis Starting Out with C++
Uitgever: Onbekend ISBN: 9780132926867 Druk: Onbekend

Documentinformatie

Heel boek samengevat?
Ja
Geüpload op
20 april 2022
Aantal pagina's
9
Geschreven in
2021/2022
Type
Samenvatting
$5.26

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
jennamortonx
3.5
(2)
Verkocht
30
Volgers
1
Items
74
Laatst verkocht
1 maand geleden




Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen