You are on page 1of 3

Chapter 1

Every C++ program should contain entry point i.e. main() function.
C++ ignores whitespaces
; semicolon used to end a statement

Every function must return something


For Ex-
return 0; (0 means success)

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::cout<< "" << variable ;

-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 ;

name of variables can't start with a digit


only underscore can be used in symbols

Types can be of two types


A.Embedded
1.int - integer numbers
unsigned int (only positive integers)
2.bool - T/F , 0-false , positive integer - false
3.char - character (range -128 to 127)
unsigned char - range 0 to 255
4.short - small no.s (range -32268 to 32267)
unsigned short (range 0 to 65536)
5.long - bigger no.s
unsigned long
6.long long - very big no.s
unsigned long long
7.float - upto 6 decimal real no.s
unsigned float
to use a floating no. , add .0f
ex - 5.0f
8.double - upto 15 decimal real no.s
unsigned double
2.User defined
Standard - String , vector

Initialize variable
setting the value in a variable
varname = data ;

Chapter 2

Extraction Operator
>>
takes value from user and place it in a variable

To get a input from user


std::cin>>varname;
to get multiple user inputs
std::cin<<var1<<var2<<var3;

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 <iostream> //input output streamm


#include <string> //string library
#include <ctime> //time library
#include <cstdlib> //standard library of c
#include <abc.h> //in a c program
#include <cabc> //in a c++ program

#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

#include <string> //it will ignore the duplicate libraries

If statement
if(condition)
{
statement;
}

If else statement
If(condition)
statement;
else
statement;