0% found this document useful (0 votes)
535 views

C Cheatsheet

This document provides a cheat sheet summarizing key concepts in C++ including data types, operators, loops, arrays, vectors, comments, escape sequences, and input/output. It lists common data types like int, float, double and their value ranges. It also covers operators like <, >, ==, arithmetic operations, logical operators, and comments. Common loops like for, while, and do-while are described. The cheat sheet also includes information about arrays like initialization and printing, as well as vectors like initialization, common operations and printing vectors.

Uploaded by

Ray Wan
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)
535 views

C Cheatsheet

This document provides a cheat sheet summarizing key concepts in C++ including data types, operators, loops, arrays, vectors, comments, escape sequences, and input/output. It lists common data types like int, float, double and their value ranges. It also covers operators like <, >, ==, arithmetic operations, logical operators, and comments. Common loops like for, while, and do-while are described. The cheat sheet also includes information about arrays like initialization and printing, as well as vectors like initialization, common operations and printing vectors.

Uploaded by

Ray Wan
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/ 1

C++ CHeat Sheet

Special Characters Operators Arithmetic Operations


// used to start a comment < less than x++ increments by one
() used in a method header to mark > greater than x-- decreases by one
parameters ==equal to x/y divide
{} encloses a group of statements .equals(for Strings) x*y multiply
““ encloses string of characters <= less than or equal to x+y additon
; marks the end of a statement >= greater than or equal to x-y subtraction
&& and x%y finding the remainder
C++ Escape Sequences || or sqrt() square root
\n newline ! not pow() power
\t tab
\b backspace Vectors
\r carriage return Random Initialization:
\\ backslash #include <time.h> Vector <datatype> Vectorname;
\’ single quote srand(time(NULL));
\” double quote rand()%(number); Operations:
vector.push_back;
Data Types Arrays vector.pop_back;
byte = -128 to 127 Initiating an array: vector.insert();
short = -32768 to 32767 int array [10];
int = -2147483648 to 2147483647 Printing an array: Printing an Vector:
long = huge number ranges for(int i = 0;
float holds decimals with 7 digits i<sizeof(array)/sizeof(array[0]);i++) for(int i = 0; i<vector.size();i++)
of accuracy { {
double holds decimals with cout<<array[i] cout<<vector[i];
15 digits of accuracy } }
Swapping:
int swap = array[i]; Printing and User Input
While Loops array[i] = array[x]; #include <iostream>
while (condition) array[x] = swap; using namespace std;
{
statement; cout<<”text”;
} int x;
cin>>x;
For Loops (pre check)
for( int i = 0; i<number; i++)
{
statement;
}

Do Loops(post check)
do{
statement;
}while(condition)

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