Introduction To C++ PDF
Introduction To C++ PDF
C++ is by far the the most popular language of choice for competitive programmers across the
world as it is usually faster than Java and Python, and most of the resources are available in C++.
C++ also has a vast library called STL(Standard Template Library) which makes life a lot easier for
competitive coders.
What a C++ program looks like
#include <bits/stdc++.h>
int main() {
return 0; }
Input output
int a;
cin >> a ;
Library :
<iostream>
Arithmetic Operators Assignment Operators
Addition +
Subtraction -
=
Multiplication *
+=
Division / -=
*=
Modulus % /= etc ...
Incrementation ++
Decrementation --
Relational operators Logical operators
== equal
!= not equal
Data types
double 8 bytes
float 4 bytes
bool 1 bytes
The if statement
a=2; a=2;
else { b = 1; }
} } } while (condition);
example2
Data structures
arrays Library for sort :
#include <bits/stdc++.h> <algorithm>
using namespace std;
int main(){
int T1[5];
int T3[2][4]; Add a function as a third
string T2[]={"hello","acm","people"}; parameter to sort in a particular
cout << "size of T2:" << sizeof(T2)/sizeof(T2[1])<<endl; order.
int T[5]={2, -3, 45}; In reverse order:
sort(T,T+5); sort(arr,arr+n,greater<int>
for (int i=0;i<5;i++) ());
cout<< T[i] <<endl;
return 0;
}
Vectors
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> v1;
for (int i = 10; i >=0; i--) { v1.push_back(i); }
sort(v1.begin(), v1.end());
for (int i = 1; i <= 10; i++) { cout<<v1[i]<<endl; }
return 0;
}
Helpful links and tools
http://library.lol/main/EABCCEC887295E5DA350302DECA61D7C CP3 download
https://ideone.com/
https://www.fosshub.com/Code-Blocks.html
https://www.youtube.com/watch?v=vLnPwxZdW4Y