0% found this document useful (0 votes)
1K views1 page

UCLA CS 31 Midterm 1 Cheat Sheet

This document provides a cheat sheet summarizing syntax for if-else statements, while loops, do-while loops, and common operators in C++. It includes brief descriptions of if-else statements that have single statements or blocks of statements for each alternative. Syntax is also shown for while and do-while loops with single statement or block bodies. Finally, common operators like arithmetic, relational, logical, assignment, and others are listed.

Uploaded by

Jacob Nisnevich
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views1 page

UCLA CS 31 Midterm 1 Cheat Sheet

This document provides a cheat sheet summarizing syntax for if-else statements, while loops, do-while loops, and common operators in C++. It includes brief descriptions of if-else statements that have single statements or blocks of statements for each alternative. Syntax is also shown for while and do-while loops with single statement or block bodies. Finally, common operators like arithmetic, relational, logical, assignment, and others are listed.

Uploaded by

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

CS 31 Midterm 1 Cheat Sheet

if-else Statement

SYNTAX: A SINGLE STATEMENT FOR EACH ALTERNATIVE
if ( Boolean_Expression)
Yes_Statement
else
No_Statement

SYNTAX: A SEQUENCE OF STATEMENTS FOR EACH
ALTERNATIVE
if ( Boolean_Expression)
{
Yes_Statement_1
Yes_Statement_2
...
Yes_Statement_Last
}
else
{
No_Statement_1
No_Statement_2
...
No_Statement_Last
}

Syntax for while and do-while Statements
A while STATEMENT WITH A SINGLE-STATEMENT
BODY
while (Boolean_Expression)
Statement
A while STATEMENT WITH A MULTISTATEMENT
BODY
while (Boolean_Expression)
{
Statement_1
Statement_2
.
.
.
Statement_Last
}
A do-while STATEMENT WITH A SINGLE-STATEMENT
BODY
do
Statement
while (Boolean_Expression);
:: Scope resolution operator
. Dot operator
-> Member selection
[] Array indexing
( ) Function call
++ Postfix increment operator (placed after the variable)
- - Postfix decrement operator (placed after the variable)
++ Prefix increment operator (placed before the variable)
- - Prefix decrement operator (placed before the variable)
! Not
- - Unary minus
+ Unary plus
* Dereference
& Address of
New Create (allocate memory)
Delete Destroy (deallocate)
Delete[] Destroy array (deallocate)
Sizeof Size of object
( ) Type cast
* Multiply
/ Divide
% Remainder (modulo)
+ Addition
- Subtraction
<< Insertion operator (console output)
>> Extraction operator (console input)
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
= = Equal
!= Not equal
&& And
|| Or
= Assignment
+= Add and assign
-= Subtract and assign
*= Multiply and assign
/= Divide and assign
%= Modulo and assign
? : Conditional operator
throw Throw an exception
, Comma operator

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy