0% found this document useful (0 votes)
134 views6 pages

Cheat Sheet For COMP218

The document lists common symbols and operators used in C++, such as :: for scope, . for member selection, and relational operators like == and !=. It also provides the syntax for common C++ commands like if/else statements, for loops, and input/output statements using cout and cin. The syntax examples include argument lists, opening and closing files, and using break and continue in loops.

Uploaded by

darwin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views6 pages

Cheat Sheet For COMP218

The document lists common symbols and operators used in C++, such as :: for scope, . for member selection, and relational operators like == and !=. It also provides the syntax for common C++ commands like if/else statements, for loops, and input/output statements using cout and cin. The syntax examples include argument lists, opening and closing files, and using break and continue in loops.

Uploaded by

darwin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

9/22/2016

eConcordia -Fundamentals of Object-Oriented Programming- Resource Centre

Print
SymbolsandOperators|SyntaxandCommands

SymbolsandOperators
Symbol

Name

::

Scopeoperator

Memberselectionoperator

++

Preorpostincrement

Preorpostdecrement

Logicalnot

Additionorunaryplus

Subtractionorunaryminus

Multiplication

http://www.econcordia.com/courses/fundamentals_oop/home/cheat_sheet.aspx

1/6

9/22/2016

eConcordia -Fundamentals of Object-Oriented Programming- Resource Centre

Division

Modulus

>

Greaterthan(relationaloperator)

>=

Greaterthanorequal(relationaloperator)

<

Lessthan(relationaloperator)

<=

Lessthanorequal(relationaloperator)

==

Equalto(relationaloperator)

!=

Notequalto(relationaloperator)

&&

And(logicaloperator)

||

Or(logicaloperator)

Assignmentoperator

+=

Addandassign

http://www.econcordia.com/courses/fundamentals_oop/home/cheat_sheet.aspx

2/6

9/22/2016

eConcordia -Fundamentals of Object-Oriented Programming- Resource Centre

Subtractandassign

*=

Multiplyandassign

/=

Divideandassign

%=

Modulusandassign

[..]

Subscript(usedwitharrays)

{..}

Marksstartandendofablock(compound
statement)

Markstheendofastatement

<<

Insertionoperator(usedwithcoutandoutputstream
variable)

>>

Extractionoperator(usedwithcinandinputstreamvariable)

//

/*..*/

Commentextendstotheendoftheline

Startandendofacommentwhichcanbe
morethanonelinelong

SyntaxandCommands
http://www.econcordia.com/courses/fundamentals_oop/home/cheat_sheet.aspx

3/6

9/22/2016

eConcordia -Fundamentals of Object-Oriented Programming- Resource Centre

ThefollowingisthesyntaxofthemainC++commandsseeninthiscourse.
Note:Thislistisnotcompleteandyoushouldrefertoyournotesand/ortextbookforallpossiblecasesforeachcommand.

Command/Statement

Syntax

Expression

Arrangementofidentifiers,literalsandoperatorsthat
canbeevaluatedtocomputeavalueofagiventype.

Assignment

Identifier=expression

Argumentlist

expression,expression,

Outputstatement

cout<<expression<<expression<<

Declaration

Typevariable,variable,...

Inputstatement

cin>>expression>>expression>>...

.get()

cin.get(variablename)

.getline(..,)

getline(cin,variable)

#include

#include<libraryname>or
#includeheaderfilename

.open()

Input/outputstreamvariable.open(filename)

http://www.econcordia.com/courses/fundamentals_oop/home/cheat_sheet.aspx

4/6

9/22/2016

eConcordia -Fundamentals of Object-Oriented Programming- Resource Centre

.close()

Input/outputstreamvariable.close()

if

if(logicalexpression)
statement

if(blocked)

if(logicalexpression)
{
statementA
statementB
...
}

if.else

if(logicalexpression)
statementA
else
statementB

while

while(logicalexpression)
statement

while(blocked)

while(logicalexpression)
{
statementA
statementB
...
}

switch

switch(expression)
{
caseconstantExpression:statement
...
default:statement
}

dowhile
http://www.econcordia.com/courses/fundamentals_oop/home/cheat_sheet.aspx

5/6

9/22/2016

eConcordia -Fundamentals of Object-Oriented Programming- Resource Centre

do
statement
while(logicalexpression)

dowhile(blocked)

do
{
statementA
statementB
...
}while(logicalexpression)

for

for(initStatementexpression1expression2)
statement

for(blocked)

for(initStatementexpression1expression2)
{
statementA
statementB
...
}

break

break

continue

continue

http://www.econcordia.com/courses/fundamentals_oop/home/cheat_sheet.aspx

6/6

You might also like