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

Cpp Cheat Sheet Expanded

This document is a cheat sheet for C++ programming, covering basic syntax, data types, operators, control statements, loops, functions, object-oriented programming, exception handling, file handling, and standard libraries. It provides code snippets and examples for each topic to aid in understanding and reference. The cheat sheet serves as a quick guide for C++ developers.

Uploaded by

raghubirkar11
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)
5 views

Cpp Cheat Sheet Expanded

This document is a cheat sheet for C++ programming, covering basic syntax, data types, operators, control statements, loops, functions, object-oriented programming, exception handling, file handling, and standard libraries. It provides code snippets and examples for each topic to aid in understanding and reference. The cheat sheet serves as a quick guide for C++ developers.

Uploaded by

raghubirkar11
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/ 3

Java Cheat Sheet

C++ Cheat Sheet

1. Basic Syntax

#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}

2. Data Types

int - Integer (e.g., 10)


float - Floating point (e.g., 10.5)
double - Double precision float
char - Single character (e.g., 'A')
bool - Boolean (true or false)
string - Text (e.g., "Hello")

3. Operators

+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
== Equal to
!= Not equal to
>= Greater than or equal to
<= Less than or equal to

4. Control Statements

if (condition) {
Java Cheat Sheet

// code block
} else {
// another code block
}

switch(expression) {
case value1:
// code
break;
default:
// code
}

5. Loops

for (int i = 0; i < 10; i++) {


cout << i << endl;
}

while (condition) {
// loop body
}

6. Functions

int add(int a, int b) {


return a + b;
}

7. Object-Oriented Programming (OOP)

class Animal {
public:
string name;
void makeSound() {
cout << "Sound" << endl;
Java Cheat Sheet

}
};
class Dog : public Animal {
public:
void makeSound() {
cout << "Bark" << endl;
}
};

8. Exception Handling

try {
int x = 10 / 0;
} catch (exception &e) {
cout << "Error: " << e.what() << endl;
}

9. File Handling

#include <fstream>
ofstream file("file.txt");
file << "Hello, C++";
file.close();

10. Standard Libraries

#include <iostream> // Input-output operations


#include <vector> // Dynamic arrays
#include <map> // Key-value pairs
#include <cmath> // Mathematical functions
#include <string> // String operations

You might also like