8 views

Uploaded by stephen562001

10 Formulas

- CPCS202-Chapter3+review
- SoftOne BlackBook ENG_v.1.0
- 3 Hours Raspberry Pi Crash Course
- 80c4cd46-6ba6-2b10-7198-ebb2d0f5650a
- Mathematics III April2003 or 320360
- 06-ConditionalProcessing
- ScriptResource(2)
- AdaptiveProgramming-AppGuideRevC
- WinMac Scalable Calendar Control
- Tehnik decexpress cxgrid.xlsx
- Type Convert Matrix
- Programming Project 1 (Racket)
- On Restricted Partitions and a Generalization of the Euler Varphi Number and the Moebius Function
- Multiplication of Large Numbers
- code.txt.txt
- Servo Main c
- prc
- User Manual
- Java Arithmetic Operators.docx
- exam-one

You are on page 1of 3

Sum of 3 integers

int x = 2;

int y = 4;

int z;

z = x + y + 3;

this code creates two integer variables x and y with initial values, creates a third

integer variable z, and sets the value of z to the value of x + y.

int x = 2;

x = x * x;

it means "take x, multipy it by itself, and assign the resulting value back to x". Now

x would have the value 4.

int x = 3;

x++;

x++;

The expression "x = x + 1;" (increasing the value of x by 1) tends to occur a lot in

programming, so C++ has a shorter way of writing this: the piece of code "x++;"

has exactly the same effect. Similarly "x = x - 1;" and "x--;" are equivalent. For

example, in the following lines of code, x has initial value 3, but has final value 5.

4. Division operation

int x = 4;

int y = x / 3;

The "int" means that y is a whole number. In this expression, the computer will

discard the non-integer part of the value of x/3. So since 4/3 = 1 + 1/3, y will get

the value 1; y is "rounded down". If the expression is negative, then the resulting

value will get "rounded up" (this is a convention, and suits the way the computer

calculates the numbers). So for example, the value of (-4)/3 = -1 - 1/3, so its

integer part is -1 (and not -2).

5. Remainder expression

int x = 11;

int y = x % 4;

The value of the expression "x % y" is the remainder of x when it is divided by y.

For example, if x has the value 11 and we write "int y = x % 4;", then z will have

the value 3.

6. Boolean function

bool a = false;

bool b = true;

bool c = (a || b) && (a || true);

Similarly to how we can write expressions for integer variables which use multiple

operators and mix variables with numbers, we can do the same with boolean

variables. For example, in the above code, c will get the value true. || is the OR

operator and && is the AND operator.

7. If statements

int x = 6;

int y = 5;

if ( x > y )

{

cout << "x is bigger than y" << endl;

}

boolean expression. We do this using an if statement. In the above code, it will

output "x is bigger than y". This is an example of conditional execution - the value

of the (boolean) comparison expression x > y is true, and so the code inside the

brackets { ... } is executed.

//x now gets the value 3^5.

x = pow( 3.0, 5 );

cout << "3^5=" << x << endl;

9. Logarithm, log of a number x

x = log( 20 );

cout << "ln(20)=" << x << endl;

This code outputs the value of the natural logarithm of 20 which is 2.9957.

// x is now square root of 25

x = sqrt( 25 );

cout << "sqrt(25)=" << x << endl;

- CPCS202-Chapter3+reviewUploaded byTopan Adi Pamungkas
- SoftOne BlackBook ENG_v.1.0Uploaded byNick
- 3 Hours Raspberry Pi Crash CourseUploaded byKhairul Yop Azreen
- 80c4cd46-6ba6-2b10-7198-ebb2d0f5650aUploaded byMamta Saboo Chakraborty
- Mathematics III April2003 or 320360Uploaded byNizam Institute of Engineering and Technology Library
- 06-ConditionalProcessingUploaded bySaif khawaja
- ScriptResource(2)Uploaded byanon_285337474
- AdaptiveProgramming-AppGuideRevCUploaded byhartman_md
- WinMac Scalable Calendar ControlUploaded bySubhasish Patnaik
- Tehnik decexpress cxgrid.xlsxUploaded byWasis Prionggo
- Type Convert MatrixUploaded bynavaneet
- Programming Project 1 (Racket)Uploaded byTheo
- On Restricted Partitions and a Generalization of the Euler Varphi Number and the Moebius FunctionUploaded byapi-26401608
- Multiplication of Large NumbersUploaded byrashed44
- code.txt.txtUploaded byEmil Tu
- Servo Main cUploaded byMihai Lucian
- prcUploaded byRicardo Mejía
- User ManualUploaded bytgdzbspikio.com
- Java Arithmetic Operators.docxUploaded byAnonymous ITnkbIEF
- exam-oneUploaded byasdf
- Server Framework - Class MethodsUploaded byawangk
- Assignment of C++ of AUSTUploaded byNazmul Hasan Pias
- SQL Reference SheetUploaded byjoseph_gaw
- untitleddocumentUploaded byapi-335751344
- PLSQLUploaded byAbdul Rahman
- InstalaçãoDoGALOPPSUploaded byLordLemos
- xulianhUploaded byDuy Hoang Duc
- SoundControlsExercise_v2Uploaded byjoe hells
- sema aydin-lesson plan 2Uploaded byapi-256269043
- Filter by Using AdvaaUploaded byzoran

- My Maid Invests in the Stock Market and Why You Should TooUploaded byAbby Balendo
- Thevenin NortonUploaded bystephen562001
- Circuit TheoremsUploaded bystephen562001
- lab01-pUploaded bystephen562001
- Ece 112 ActivityUploaded bystephen562001
- Miracle Grow Chart TemplateUploaded bystephen562001
- What is the Difference Between Computer Science-Computer Engineering-ITUploaded bystephen562001
- USTP AddressUploaded bystephen562001
- On the Wings of Love - Jeffrey OsborneUploaded byjuan
- s9Uploaded bystephen562001
- Normal CurvesUploaded bystephen562001
- 10 FormulasUploaded bystephen562001
- GEC_Rev1Uploaded bystephen562001
- Topological Sorting of SubjectsUploaded bystephen562001
- Syllabus OBE TemplateUploaded bystephen562001
- Memo-for-the-deadline-submission-of-IPCR.pdfUploaded bystephen562001
- Memo-for-the-deadline-submission-of-IPCR.pdfUploaded bystephen562001
- The Vocal Union Only One Lyrics _ JustsomelyricsUploaded bystephen562001
- ReadmeUploaded bycarlos valdez
- Amazing Grace.pdfUploaded bystephen562001
- ForevermoreUploaded bystephen562001
- Malware Scan Result 0725Uploaded bystephen562001
- Malware Scan Result 0308Uploaded bystephen562001
- ex1-2004akUploaded bystephen562001
- ex1-2004Uploaded bystephen562001
- ex1-2003akUploaded bystephen562001
- ex1-2003Uploaded bystephen562001
- ex1-2002akUploaded bystephen562001

- Datasheet 1385Uploaded byrtv_domoratskaya
- Tooling for die-castingUploaded byIliyan Draganov
- 22261 NobelReplace Tapered Sales Brochure GB Tcm61-19282Uploaded byAna Sofia Rodriguez
- Quality of Reinforced Concrete Used on Selected Buildings in Nairobi, KenyaUploaded byWillykateKairu
- WV-CS570 Operating InstructionsUploaded byRaghvendra Mani
- ARPUploaded byPrateek Dotasara
- 【豆知識】腐食 Trivia About CorrosionUploaded bycharzree
- Steam TableUploaded byKrismawan Saptya Yudha
- 1Uploaded byRomario Donaldo Solis Valle
- PreStressed Slab Design 2017 v1.0Uploaded byHatem Abu asbeh
- Calculation of Gear Dimensions _ KHK GearsUploaded byHamid Masood
- Broadcom NetXtremeII ServerUploaded byGeta Bucur
- Electrical Safety i Fact SheetUploaded byFallenKiwi
- i_optionsUploaded bypathagon1976
- Injection MouldingUploaded byretnadiah354
- Nuwakot District Rate 071.72Uploaded byOo Pen Dra
- resume update 2015 compressed font version and editeddocxUploaded byapi-240441428
- E13 - Management of Traffic During Construction v1.4Uploaded byJoseph Emmanuel Nainggolan
- Sec_630.pdfUploaded byJose Ines
- 3d ics-Seminar-Report-‘08Uploaded bySanthanu Surendran
- LVRT2 CourseManual English SampleUploaded byAnastasios Karahalios
- Katflow_150Uploaded bytomi wirawan
- 12102013resysta PortfolioUploaded byKiran Kumar Akula
- DRM Prefab Workshop & WarehouseUploaded byDeepak Deepak
- 2012 MMU Expanding the Ecosystem of Mobile MoneyUploaded byNagham Hamdan
- Field Resonance Propulsion PDF Tech ReportsUploaded byRhiannon
- GuestOS GuideUploaded byvenki00
- CT Tutorial Lecture-6Uploaded byshehnozmohd
- MITESD_934S10_lec_02Uploaded byBalaji Kannan
- Application of Game Theory in Wireless Communication NetworksUploaded byMotasim_m