On Github lepisma / cpp-lecture
int x = 34;
int a = 5; char b = 'h';
#include<iostream>
cout << "Hello";
int x = 5; cout << "Hello, x = " << x;
int number; cin >> number; int twice_of_number = number * 2; cout << twice_of_number;
cout << "Sample Output"; system("pause");
int marks = 100; if (marks==100) cout << "Congrats !! Chapo.";
int marks = 88; if (marks==100) cout << "Congrats !! Chapo."; else cout << ":|";
switch (x) { case 1: cout << "x is 1"; break; case 2: cout << "x is 2"; break; default: cout << "value of x unknown"; }
int arr[3]; arr[0] = 34; arr[1] = 54; arr[2] = 13;
int arr[3] = {34, 54, 13};
char y = 'c'; char array[4] = {'a', 'b', 'f', 'd'}; array[2] = y; // now array is {'a', 'b', 'c', 'd'}
for (initialize; conditional statement; update){ do this code; }
int years[4] = {2002, 2007, 2010, 2013}; for (int i = 0; i < 4; i++){ cout << years[i] << "\n"; }
while (conditional statement is true) { //do this code; }
int years[4] = {2002, 2007, 2010, 2013}; int i = 0; while(i<4){ cout << years[i] << "\n"; i += 1; }
int years[4] = {2002, 2007, 2010, 2013}; int i = 0; do{ cout << years[i] << "\n"; i += 1; } while(i < 4);
/* C++ Program Author SDSLabs */ #include<iostream> //include the header files you need here using namespace std; int main() // it all begins from here { //your code here return 0; }