Professional Documents
Culture Documents
Every C++ program should contain entry point i.e. main() function.
C++ ignores whitespaces
; semicolon used to end a statement
libraries
#include <iostream> (input output stream)
#include <iomanip> (input output manipulate)
functions
main() (Entry Point)
cout() (character output)
-insert operator
<<
works as equalto
-for printing
std::cout << yfu << "" << std::endl;
endl changes the line (end line) & also flushes or cleares the current buffer.
-std::setw(5)
set the width of the chracter to 5 char
adds spaces if required before the string
-std::setfill('0')
fill up the empty spaces with whatever u want ,here with 0s
scope operator
::
used to call a function
For Ex-
using namespace std;
cout << "Hello World";
or
std::cout << "Hello World";
dcelare variables
DataType Varname ;
Initialize variable
setting the value in a variable
varname = data ;
Chapter 2
Extraction Operator
>>
takes value from user and place it in a variable
Constant Variables
const type var = 45 ;
type const var = 45;
you can also use this syntax before main()
#define varname 35
Auto keyword
it auto detect the type of variable
comments
// - single line comments
/* */ - multi line comments
Chapter 3
Libraries
#include "Somelib.h" //non system library , should exist in the same folder as
project
#include "path/of/the/file/Somelib.h" //defined the path already
If statement
if(condition)
{
statement;
}
If else statement
If(condition)
statement;
else
statement;