SlideShare a Scribd company logo
Tutorials For
Beginners
Introduction to
programming
languages
2
● computer program
● Programming
● Programmer
● Source Code (Code)
● Hardware
● Program Execution
● Machine Language
● Assembly Language
● High Level Language
3
High Level Language Assembly Language Machine Language
4
Compiler VS Interpreter
5
Compiler
Interpreter
6
Compiler VS Interpreter
Compiler
● Scans whole program at
one go
● Errors are shown at the
end
● Compilation is slow
● Execution is fast
● Generates an intermediate
code
● C,C++
Interpreter
● Translate one statement
at a time(line by line)
● Errors are shown line by
line
● Translation is done fast
● Execution is slow
● Execute the program
without intermediate code
● Python,Javascript
7
To Run C/C++ program we need :
C/C++ Compiler and VS code setup
● Text Editor (VS code)
● C++ compiler (GCC compiler)
● C/C++ - VS code extension
● Code Runner - VS code extension
Extra Setup:
8
How to run
C/C++
program in
mobile ?
Basic Structure Of
C++ Program
10
INPUT/OUTPUT
In C++
● CIN and COUT
● Extraction >> and insertion << operator
● endl vs n
● Code Runner(Extension) issue with CIN
Comments in C++
11
● SIngle Line Comment -//
● Multiline Comment - /* */
12
Variables & Data Types
in C++
13
Rules for naming a variable
● Variable names in C++ can range from 1 to 255
characters.
● All variable names must begin with a letter of the
alphabet or an underscore(_).
● After the first initial letter, variable names can also
contain letters and numbers.
● Variable names are case sensitive.
● No spaces or special characters are allowed.
● You cannot use a C++ keyword (a reserved word)
as a variable name.
14
Modifiers in C++
15
16
Data Type Size Value Range
int 4 Bytes -2147483648 to 2147483647
char 1 Bytes -127 to 127 or 0 to 255
float 4 Bytes - 3.4E38 to 3.4E38
double 8 Byte - 1.7E308 to 1.7E + 308
bool 1 Byte
Modifiers in c++
17
● Signed
● unsigned
● short
● long
18
Data Type Size Value Range
int 4 Bytes -2147483648 to 2147483647
Unsigned int 4 Bytes 0 to 4294967295
signed int 4 Bytes -2147483648 to 2147483647
Sort int 2 Bytes -32768 to 32767
long int 8 Bytes -2,147,483,648 to 2,147,483,647
char 1 Bytes -127 to 127 or 0 to 255
Unsigned char 1 Bytes 0 to 255
Signed char 1 Byte -127 to 127
float 4 Bytes - 3.4E38 to 3.4E38
double 8 Byte - 1.7E308 to 1.7E + 308
long double 12 Bytes - 3.4E4932 to 1.1E + 4932
bool 1 Byte
Scope of Variables
in C++
● Local Variables
● Global Variables
Constant Variables
● A const variable must be assigned a value at the
time of its declaration.
● If we declare a variable as const, we cannot
change its value.
● Once initialized, if we try to change its value, then
we will get compilation error.
20
Manipulators in c++
21
Manipulator Purpose Header File
endl causes line feed to be inserted i.e. ‘n’ iostream.h
dec,oct,hex set the desired number system iostream.h
setbase (b) output integers in base b iomanip.h
setw(w) read or write values to w characters iomanip.h
setfill (c) fills the whitespace with character c iomanip.h
setprecision(n) set floating point precision to n iomanip.h
Operators in C++
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Bitwise Operators
6. Other Operators
22
Operators in C++
23
24
Arithmetic Operators
Operator Description Example
+ Adds two operands A+B=30
- Subtracts second operand from the first A-B=10
* Multiplies both operands A*B=200
/ Divides numerator by de-numerator A/B=2
% Modulus operator – the result is the remainder of the
division
A%B=0
++ Increment operator, increases integer value by one A++ will give 21
-- Decrement operator, decreases integer value by one B-- will give 9
Assume A=20 and B=10
25
Relational Operators
Operator Description Example
== Checks if the values of two operands are equal or not. (A == B) = false
!= Checks if the values of two operands are equal or not. (A != B) = true
> Checks if the value of left operand is greater than the value of
right operand
(A>B) = true
< Checks if the value of left operand is less than the value of right
operand,
(A<B) = false
>= Checks if the value of left operand is greater than or equal to
the value of right operand
(A>=B) = true
<= Checks if the value of left operand is less than or equal to the
value of right operand
(A<=B) = false
Assume A=20 and B=10
26
Logical Operators
Operator Description Example
&& Logical AND. True only if all the operands are true. (A>10 && B>20) = false
|| Logical OR. True if at least one of the operands is true. (A>10 || B>20) = true
! Called Logical NOT Operator. Use to reverses the
logical state of its operand. If a condition is true, then
Logical NOT operator will make false.
!(A>10) = false
Assume A=20 and B=10
27
Logical Operators
A B A && B A|| B !A
false false false false true
false true false true true
true false false true false
true true true true false
28
Assignment Operators
Operator Description Example
= Assigns values from right side operands to left side
operand.
A =5
+= It adds right operand to the left operand and assign the
result to left operand
A +=5 same as A=A+5
-= It subtracts right operand from the left operand and
assign the result to left operand.
A-=5 same as A=A-5
*= It multiplies right operand with the left operand and
assign the result to left operand.
A*=5 same as A=A*5
/= It divides left operand with the right operand and assign
the result to left operand.
A/=5 same as A=A/5
%= It takes modulus using two operands and assign the
result to left operand.
A%=5 same as A=A%5
29
Bitwise Operators
A B A&B A|B A^B ~A
0 0 0 0 0 1
0 1 0 1 1 1
1 0 0 1 1 0
1 1 1 1 0 0
30
Bitwise Operators
Operator Description Example
& Binary AND Operator copies a bit to the result if it exists in
both operands.
(A & B) = 1 (00000001)
| Binary OR Operator copies a bit if it exists in either operand. (A | B) = 3 (00000011)
^ Binary XOR Operator copies the bit if it is set in one operand
but not both.
(A ^ B) = 2 (00000010)
~ Binary Ones Complement Operator is unary and has the
effect of 'flipping' bits.
!A=!3= -4 (11111100)
<< Binary Left Shift Operator. The left operands value is moved left
by the number of bits specified by the right operand.
A<<1 = 6 (00000110)
>> Binary Right Shift Operator. The left operands value is moved right by
the number of bits specified by the right operand.
A>>1 = 1 (00000001)
A=3 (0000 0011 ) and B=1 (0000 0001)
31
Other Operators
Operator Description Example
sizeof Returns the size of variable sizeof(int) =4
Condition ? x:y If condition is true then it returns value of X
otherwise returns value of Y
Int y=20;
int x= (y < 10) ? 30 : 40;
cast Convert one data type to other int(2.2000) = 2
,
causes a sequence of operations to be
performed. The value of the entire comma
expression is the value of the last expression
of the comma-separated list.
Int j=1;
int i= (j++, j+10, j+20);
& Returns the address of a variable
* Is pointer to a variable
32
Operators Precedence and Associativity
Category Operator Associativity
Postfix () [] -> . ++ - - Left to right
Unary + - ! ~ ++ - - (type)* & sizeof Left to right
Multiplicative * / % Left to right
Additive + - Left to right
Shift << >> Left to right
Relational < <= > >= Left to right
Equality == != Left to right
Bitwise AND & Left to right
33
Operators Precedence and Associativity
Category Operator Associativity
Bitwise XOR ^ Left to right
Bitwise OR | Left to right
Logical AND && Left to right
Logical OR || Left to right
Conditional ?: Right to left
Assignment = += -= *= /= %=>>= <<= &= ^= |= Right to left
Comma , Left to right
Increment (++) and decrement (--)
34
1. The increment operator ++ increases the value of a variable
by 1
2. Similarly, the decrement operator -- decreases the value of a
variable by 1
3. Increment and decrement operators can be used only with
variables. They can't be used with constants or
expressions.
Eg. x=5,y=6;
x++; // valid
5++; // invalid
(x+y)++; // invalid
Types of Increment ++ operator
35
Increment ++
Post-increment
Eg. a++
Pre-increment
Eg. ++a
1. In pre-increment first increment the value of variable and then
used inside the expression (initialize into another variable).
2. In post-increment first value of variable is use in the expression
(initialize into another variable) and then increment the value of
variable.
Types of decrement -- operator
36
decrement --
Post-decrement
Eg. a--
Pre-decrement
Eg. --a
1. In pre-decrement first decrement the value of variable and then
used inside the expression (initialize into another variable).
2. In post-decrement first value of variable is use in the expression
(initialize into another variable) and then decrement the value of
variable.
37
● If-else
● Switch
● For Loop
● While loop
● Do-While Loop
● Break /Continue
● Goto
Control Statement
38
● If statement
● If...else statement
● If…else if…else statement
● Nested if statement
If-else
39
● Write a C++ program to accept two integers and check whether they are
equal or not.
● Write a C++ program to accept a integer and check whether number is
even or odd.
● Write a C++ program to accept a integer and check whether number is
positive,negative or zero.
● Write a program in C++ to read any day number in integer and display day
name in the word.
● Write a C++ program to accept two integers and find maximum between
two numbers.
If-else practice questions :
40
switch-case
41
Switch-case practice questions :
● Write a C++ program to print day of week name using switch case.
● Write a C++ program print total number of days in a month using switch
case.
● Write a C++ program to accept a integer and check whether number is
positive,negative or zero using switch case.
● Write a program in C++ to read any day number in integer and display day
name in the word using switch case.
42
Loops in C++ :
● For loop
● While loop
● Do-while loop
43
For loop :
Syntax :
for(initialization;condition;increment){
// your code
}
Example:
for(int i=0;i<5;i++){
cout<<i<<”n”;
}
44
While loop :
Syntax :
while(condition){
// your code
}
Example:
int i=0;
while(i<10){
cout<<i<<”n”;
i++;
}
45
do-while loop :
Syntax :
do{
// your code
}while(condition)
Example:
int i=0;
do{
cout<<i<<”n”;
i++;
}while(i<10)
46
Loop practice questions :
● Write a program in C++ to find the first 10 natural numbers
○ 1 2 3 4 5 6 7 8 9 10
● Write a program in C++ to print a square pattern with # character.
● Write a program in C++ to find the factorial of a number.
● Write a program in C++ to display the pattern like right angle triangle using
an asterisk.
47
Loop practice questions :
● Write a program in C++ to display the pattern like right angle triangle using
an asterisk.
● Write a program in C++ to make such a pattern like a pyramid with an
asterisk.
48
Break
● In C++, the break statement terminates the loop when it is encountered.
49
Continue
● In C++, the continue is used to skip the current iteration of the loop and the
control of the program goes to the next iteration
C++ Functions
50
C++ Functions
51
● A function is a block of code that performs a specific task.
● Functions help us in reducing code redundancy.
● If functionality is performed at multiple places in software,
then rather than writing the same code, again and again, we
create a function and call it everywhere.
● This also helps in maintenance as we have to change at one
place if we make future changes to the functionality.
C++ Functions
52
● There are two types of function:
○ Library Functions (Built in functions)
○ User defined functions
● Function declaration
returnType functionName (parameter1, parameter2,...) {
// function body
}
Function Prototype
53
● The code of function declaration should be before the
function call.
● However, if we want to define a function after the function
call, we need to use the function prototype.
● Function prototype is a declaration statement.
type function-name (arguments-list);
Eg. int sum(int num1,int num2);
OR
int sum(int,int); // Variable name is optional
Default Parameters
54
● In C++, we can provide default values for function parameters.
● In this case, when we invoke the function, we don’t specify
parameters.
● Instead, the function takes the default parameters that are
provided in the prototype.
● Note that while providing default parameters, we always start from
the right-most parameter. Also, we cannot skip a parameter in
between and provide a default value for the next parameter.
● Eg.
Void add(int x, int y, int z = 0)
Default parameter
Const Parameters
55
● We can pass constant parameters to functions using the
‘const’ keyword.
● When a parameter or reference is const, it cannot be
changed inside the function.
Void add(const x, const y)
Const parameter
Inline Functions
56
● When we make a function call, internally it involves a compiler
storing the state of the program on a stack before passing
control to the function.
● When the function returns, the compiler has to retrieve the
program state back and continue from where it left.
● This poses an overhead. Hence, in C++ whenever we have a
function consisting of few statements, there is a facility that
allows it to expand inline.
● This is done by making a function inline. So inline functions are
the functions that are expanded at runtime, saving the efforts to
call the function and do the stack modifications.
Inline Functions
57
● But even if we make a function as inline, the compiler
does not guarantee that it will be expanded at runtime.
● In other words, it’s completely dependent on the compiler
to make the function inline or not.
● Eg.
inline int addition(const int a,const int b)
Ad

More Related Content

Similar to C++ notes.pdf BASIC C++ NOTES FOR BEGGINERS (20)

Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
PreSolutions Softwares
 
btwggggggggggggggggggggggggggggggisop correct (1).pptx
btwggggggggggggggggggggggggggggggisop correct (1).pptxbtwggggggggggggggggggggggggggggggisop correct (1).pptx
btwggggggggggggggggggggggggggggggisop correct (1).pptx
Orin18
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
CtOlaf
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
LEOFAKE
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.ppt
balewayalew
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
Rohit Shrivastava
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
Rohit Shrivastava
 
11operator in c#
11operator in c#11operator in c#
11operator in c#
Sireesh K
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
Fiaz Khokhar
 
Python tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingPython tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online Training
Rahul Tandale
 
SPL 6 | Operators in C
SPL 6 | Operators in CSPL 6 | Operators in C
SPL 6 | Operators in C
Mohammad Imam Hossain
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
Thesis Scientist Private Limited
 
Coper in C
Coper in CCoper in C
Coper in C
thirumalaikumar3
 
Report on c
Report on cReport on c
Report on c
jasmeen kr
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
Shobi P P
 
C language
C languageC language
C language
Mohamed Bedair
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
Prof Ansari
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
Stoian Kirov
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
michaelaaron25322
 
btwggggggggggggggggggggggggggggggisop correct (1).pptx
btwggggggggggggggggggggggggggggggisop correct (1).pptxbtwggggggggggggggggggggggggggggggisop correct (1).pptx
btwggggggggggggggggggggggggggggggisop correct (1).pptx
Orin18
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
CtOlaf
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
LEOFAKE
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.ppt
balewayalew
 
11operator in c#
11operator in c#11operator in c#
11operator in c#
Sireesh K
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
Fiaz Khokhar
 
Python tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online TrainingPython tutorials for beginners | IQ Online Training
Python tutorials for beginners | IQ Online Training
Rahul Tandale
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
Shobi P P
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
Prof Ansari
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
Stoian Kirov
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
michaelaaron25322
 

More from AAFREEN SHAIKH (20)

3-inheritanc-and-variation.pdf HSC BIOLOGY 3-inheritanc-and-variation
3-inheritanc-and-variation.pdf  HSC BIOLOGY 3-inheritanc-and-variation3-inheritanc-and-variation.pdf  HSC BIOLOGY 3-inheritanc-and-variation
3-inheritanc-and-variation.pdf HSC BIOLOGY 3-inheritanc-and-variation
AAFREEN SHAIKH
 
1-reproduction-in-plants-assignment-notes.pdf
1-reproduction-in-plants-assignment-notes.pdf1-reproduction-in-plants-assignment-notes.pdf
1-reproduction-in-plants-assignment-notes.pdf
AAFREEN SHAIKH
 
Rotational-Dynamics-ppt3.pdf HSC PHYSICS CHAPTER 1 ROTATIONAL DYNAMIC PART 3
Rotational-Dynamics-ppt3.pdf HSC PHYSICS CHAPTER 1 ROTATIONAL DYNAMIC PART 3Rotational-Dynamics-ppt3.pdf HSC PHYSICS CHAPTER 1 ROTATIONAL DYNAMIC PART 3
Rotational-Dynamics-ppt3.pdf HSC PHYSICS CHAPTER 1 ROTATIONAL DYNAMIC PART 3
AAFREEN SHAIKH
 
Rotational-Dynamics-ppt2.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-2
Rotational-Dynamics-ppt2.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-2Rotational-Dynamics-ppt2.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-2
Rotational-Dynamics-ppt2.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-2
AAFREEN SHAIKH
 
Rotational-Dynamics-ppt1.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-1
Rotational-Dynamics-ppt1.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-1Rotational-Dynamics-ppt1.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-1
Rotational-Dynamics-ppt1.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-1
AAFREEN SHAIKH
 
assesment-12th BY AAFREEN SHAIKH.pdf HSC assesment
assesment-12th BY AAFREEN SHAIKH.pdf HSC assesmentassesment-12th BY AAFREEN SHAIKH.pdf HSC assesment
assesment-12th BY AAFREEN SHAIKH.pdf HSC assesment
AAFREEN SHAIKH
 
English-Paper-Pattern.pdf HSC ENGLISH PAPER PATTERN
English-Paper-Pattern.pdf  HSC ENGLISH PAPER PATTERNEnglish-Paper-Pattern.pdf  HSC ENGLISH PAPER PATTERN
English-Paper-Pattern.pdf HSC ENGLISH PAPER PATTERN
AAFREEN SHAIKH
 
Lesson-6-Ecommerce-&-EGovernance BY AAFREEN SHAIKH.pdf
Lesson-6-Ecommerce-&-EGovernance BY AAFREEN SHAIKH.pdfLesson-6-Ecommerce-&-EGovernance BY AAFREEN SHAIKH.pdf
Lesson-6-Ecommerce-&-EGovernance BY AAFREEN SHAIKH.pdf
AAFREEN SHAIKH
 
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHPLesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
AAFREEN SHAIKH
 
Lesson-4-Emerging-Technology BY AAFREEN SHAIKH.pdf
Lesson-4-Emerging-Technology BY AAFREEN SHAIKH.pdfLesson-4-Emerging-Technology BY AAFREEN SHAIKH.pdf
Lesson-4-Emerging-Technology BY AAFREEN SHAIKH.pdf
AAFREEN SHAIKH
 
Std.-XI-Unit-Test-No.-1-Third-Practice-Test-By-Prof.-Aafreen Shaikh.docx
Std.-XI-Unit-Test-No.-1-Third-Practice-Test-By-Prof.-Aafreen Shaikh.docxStd.-XI-Unit-Test-No.-1-Third-Practice-Test-By-Prof.-Aafreen Shaikh.docx
Std.-XI-Unit-Test-No.-1-Third-Practice-Test-By-Prof.-Aafreen Shaikh.docx
AAFREEN SHAIKH
 
Std.-XI-Unit-Test-2-By-Prof.-aafreen shaikh.pdf
Std.-XI-Unit-Test-2-By-Prof.-aafreen shaikh.pdfStd.-XI-Unit-Test-2-By-Prof.-aafreen shaikh.pdf
Std.-XI-Unit-Test-2-By-Prof.-aafreen shaikh.pdf
AAFREEN SHAIKH
 
Std.-XI-Unit-Test-No.1-For-First-Term-By-Prof.-Aafreen Shaikh.pdf
Std.-XI-Unit-Test-No.1-For-First-Term-By-Prof.-Aafreen Shaikh.pdfStd.-XI-Unit-Test-No.1-For-First-Term-By-Prof.-Aafreen Shaikh.pdf
Std.-XI-Unit-Test-No.1-For-First-Term-By-Prof.-Aafreen Shaikh.pdf
AAFREEN SHAIKH
 
GEOGRAPHY QUESTION PAPER.pdf HSC GEOGRAPHY QUESTION PAPER
GEOGRAPHY QUESTION PAPER.pdf HSC GEOGRAPHY QUESTION PAPERGEOGRAPHY QUESTION PAPER.pdf HSC GEOGRAPHY QUESTION PAPER
GEOGRAPHY QUESTION PAPER.pdf HSC GEOGRAPHY QUESTION PAPER
AAFREEN SHAIKH
 
CHEMISTRY QUESTION PAPERS.pdf HSC CHEMISTRY QUESTION PAPERS
CHEMISTRY QUESTION PAPERS.pdf HSC CHEMISTRY QUESTION PAPERSCHEMISTRY QUESTION PAPERS.pdf HSC CHEMISTRY QUESTION PAPERS
CHEMISTRY QUESTION PAPERS.pdf HSC CHEMISTRY QUESTION PAPERS
AAFREEN SHAIKH
 
marathi question paper.pdf hsc marathi prelims sample question papers
marathi question paper.pdf hsc marathi prelims sample question papersmarathi question paper.pdf hsc marathi prelims sample question papers
marathi question paper.pdf hsc marathi prelims sample question papers
AAFREEN SHAIKH
 
Ls-No-1 Web Publishing Notes.pdf 12th information technology chapter 1
Ls-No-1 Web Publishing Notes.pdf 12th information technology chapter 1Ls-No-1 Web Publishing Notes.pdf 12th information technology chapter 1
Ls-No-1 Web Publishing Notes.pdf 12th information technology chapter 1
AAFREEN SHAIKH
 
Solutions - formula sheet.pdf 12TH IMPORTANT FORMULA SHEET CHAP 3 CHEMISTRY
Solutions - formula sheet.pdf 12TH IMPORTANT FORMULA SHEET CHAP 3 CHEMISTRYSolutions - formula sheet.pdf 12TH IMPORTANT FORMULA SHEET CHAP 3 CHEMISTRY
Solutions - formula sheet.pdf 12TH IMPORTANT FORMULA SHEET CHAP 3 CHEMISTRY
AAFREEN SHAIKH
 
Some basic Concepts of Chemistry.pdf class 11th science chemistry chapter 1 s...
Some basic Concepts of Chemistry.pdf class 11th science chemistry chapter 1 s...Some basic Concepts of Chemistry.pdf class 11th science chemistry chapter 1 s...
Some basic Concepts of Chemistry.pdf class 11th science chemistry chapter 1 s...
AAFREEN SHAIKH
 
HTML NOTES.ppt BASIC HTML PROGRAMING NOTES
HTML NOTES.ppt BASIC HTML PROGRAMING NOTESHTML NOTES.ppt BASIC HTML PROGRAMING NOTES
HTML NOTES.ppt BASIC HTML PROGRAMING NOTES
AAFREEN SHAIKH
 
3-inheritanc-and-variation.pdf HSC BIOLOGY 3-inheritanc-and-variation
3-inheritanc-and-variation.pdf  HSC BIOLOGY 3-inheritanc-and-variation3-inheritanc-and-variation.pdf  HSC BIOLOGY 3-inheritanc-and-variation
3-inheritanc-and-variation.pdf HSC BIOLOGY 3-inheritanc-and-variation
AAFREEN SHAIKH
 
1-reproduction-in-plants-assignment-notes.pdf
1-reproduction-in-plants-assignment-notes.pdf1-reproduction-in-plants-assignment-notes.pdf
1-reproduction-in-plants-assignment-notes.pdf
AAFREEN SHAIKH
 
Rotational-Dynamics-ppt3.pdf HSC PHYSICS CHAPTER 1 ROTATIONAL DYNAMIC PART 3
Rotational-Dynamics-ppt3.pdf HSC PHYSICS CHAPTER 1 ROTATIONAL DYNAMIC PART 3Rotational-Dynamics-ppt3.pdf HSC PHYSICS CHAPTER 1 ROTATIONAL DYNAMIC PART 3
Rotational-Dynamics-ppt3.pdf HSC PHYSICS CHAPTER 1 ROTATIONAL DYNAMIC PART 3
AAFREEN SHAIKH
 
Rotational-Dynamics-ppt2.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-2
Rotational-Dynamics-ppt2.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-2Rotational-Dynamics-ppt2.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-2
Rotational-Dynamics-ppt2.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-2
AAFREEN SHAIKH
 
Rotational-Dynamics-ppt1.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-1
Rotational-Dynamics-ppt1.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-1Rotational-Dynamics-ppt1.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-1
Rotational-Dynamics-ppt1.pdf HSC PHYSICS CHAPTER 1 Rotational-Dynamics PART-1
AAFREEN SHAIKH
 
assesment-12th BY AAFREEN SHAIKH.pdf HSC assesment
assesment-12th BY AAFREEN SHAIKH.pdf HSC assesmentassesment-12th BY AAFREEN SHAIKH.pdf HSC assesment
assesment-12th BY AAFREEN SHAIKH.pdf HSC assesment
AAFREEN SHAIKH
 
English-Paper-Pattern.pdf HSC ENGLISH PAPER PATTERN
English-Paper-Pattern.pdf  HSC ENGLISH PAPER PATTERNEnglish-Paper-Pattern.pdf  HSC ENGLISH PAPER PATTERN
English-Paper-Pattern.pdf HSC ENGLISH PAPER PATTERN
AAFREEN SHAIKH
 
Lesson-6-Ecommerce-&-EGovernance BY AAFREEN SHAIKH.pdf
Lesson-6-Ecommerce-&-EGovernance BY AAFREEN SHAIKH.pdfLesson-6-Ecommerce-&-EGovernance BY AAFREEN SHAIKH.pdf
Lesson-6-Ecommerce-&-EGovernance BY AAFREEN SHAIKH.pdf
AAFREEN SHAIKH
 
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHPLesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
AAFREEN SHAIKH
 
Lesson-4-Emerging-Technology BY AAFREEN SHAIKH.pdf
Lesson-4-Emerging-Technology BY AAFREEN SHAIKH.pdfLesson-4-Emerging-Technology BY AAFREEN SHAIKH.pdf
Lesson-4-Emerging-Technology BY AAFREEN SHAIKH.pdf
AAFREEN SHAIKH
 
Std.-XI-Unit-Test-No.-1-Third-Practice-Test-By-Prof.-Aafreen Shaikh.docx
Std.-XI-Unit-Test-No.-1-Third-Practice-Test-By-Prof.-Aafreen Shaikh.docxStd.-XI-Unit-Test-No.-1-Third-Practice-Test-By-Prof.-Aafreen Shaikh.docx
Std.-XI-Unit-Test-No.-1-Third-Practice-Test-By-Prof.-Aafreen Shaikh.docx
AAFREEN SHAIKH
 
Std.-XI-Unit-Test-2-By-Prof.-aafreen shaikh.pdf
Std.-XI-Unit-Test-2-By-Prof.-aafreen shaikh.pdfStd.-XI-Unit-Test-2-By-Prof.-aafreen shaikh.pdf
Std.-XI-Unit-Test-2-By-Prof.-aafreen shaikh.pdf
AAFREEN SHAIKH
 
Std.-XI-Unit-Test-No.1-For-First-Term-By-Prof.-Aafreen Shaikh.pdf
Std.-XI-Unit-Test-No.1-For-First-Term-By-Prof.-Aafreen Shaikh.pdfStd.-XI-Unit-Test-No.1-For-First-Term-By-Prof.-Aafreen Shaikh.pdf
Std.-XI-Unit-Test-No.1-For-First-Term-By-Prof.-Aafreen Shaikh.pdf
AAFREEN SHAIKH
 
GEOGRAPHY QUESTION PAPER.pdf HSC GEOGRAPHY QUESTION PAPER
GEOGRAPHY QUESTION PAPER.pdf HSC GEOGRAPHY QUESTION PAPERGEOGRAPHY QUESTION PAPER.pdf HSC GEOGRAPHY QUESTION PAPER
GEOGRAPHY QUESTION PAPER.pdf HSC GEOGRAPHY QUESTION PAPER
AAFREEN SHAIKH
 
CHEMISTRY QUESTION PAPERS.pdf HSC CHEMISTRY QUESTION PAPERS
CHEMISTRY QUESTION PAPERS.pdf HSC CHEMISTRY QUESTION PAPERSCHEMISTRY QUESTION PAPERS.pdf HSC CHEMISTRY QUESTION PAPERS
CHEMISTRY QUESTION PAPERS.pdf HSC CHEMISTRY QUESTION PAPERS
AAFREEN SHAIKH
 
marathi question paper.pdf hsc marathi prelims sample question papers
marathi question paper.pdf hsc marathi prelims sample question papersmarathi question paper.pdf hsc marathi prelims sample question papers
marathi question paper.pdf hsc marathi prelims sample question papers
AAFREEN SHAIKH
 
Ls-No-1 Web Publishing Notes.pdf 12th information technology chapter 1
Ls-No-1 Web Publishing Notes.pdf 12th information technology chapter 1Ls-No-1 Web Publishing Notes.pdf 12th information technology chapter 1
Ls-No-1 Web Publishing Notes.pdf 12th information technology chapter 1
AAFREEN SHAIKH
 
Solutions - formula sheet.pdf 12TH IMPORTANT FORMULA SHEET CHAP 3 CHEMISTRY
Solutions - formula sheet.pdf 12TH IMPORTANT FORMULA SHEET CHAP 3 CHEMISTRYSolutions - formula sheet.pdf 12TH IMPORTANT FORMULA SHEET CHAP 3 CHEMISTRY
Solutions - formula sheet.pdf 12TH IMPORTANT FORMULA SHEET CHAP 3 CHEMISTRY
AAFREEN SHAIKH
 
Some basic Concepts of Chemistry.pdf class 11th science chemistry chapter 1 s...
Some basic Concepts of Chemistry.pdf class 11th science chemistry chapter 1 s...Some basic Concepts of Chemistry.pdf class 11th science chemistry chapter 1 s...
Some basic Concepts of Chemistry.pdf class 11th science chemistry chapter 1 s...
AAFREEN SHAIKH
 
HTML NOTES.ppt BASIC HTML PROGRAMING NOTES
HTML NOTES.ppt BASIC HTML PROGRAMING NOTESHTML NOTES.ppt BASIC HTML PROGRAMING NOTES
HTML NOTES.ppt BASIC HTML PROGRAMING NOTES
AAFREEN SHAIKH
 
Ad

Recently uploaded (20)

SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Ad

C++ notes.pdf BASIC C++ NOTES FOR BEGGINERS

  • 2. Introduction to programming languages 2 ● computer program ● Programming ● Programmer ● Source Code (Code) ● Hardware ● Program Execution ● Machine Language ● Assembly Language ● High Level Language
  • 3. 3 High Level Language Assembly Language Machine Language
  • 6. 6 Compiler VS Interpreter Compiler ● Scans whole program at one go ● Errors are shown at the end ● Compilation is slow ● Execution is fast ● Generates an intermediate code ● C,C++ Interpreter ● Translate one statement at a time(line by line) ● Errors are shown line by line ● Translation is done fast ● Execution is slow ● Execute the program without intermediate code ● Python,Javascript
  • 7. 7 To Run C/C++ program we need : C/C++ Compiler and VS code setup ● Text Editor (VS code) ● C++ compiler (GCC compiler) ● C/C++ - VS code extension ● Code Runner - VS code extension Extra Setup:
  • 10. 10 INPUT/OUTPUT In C++ ● CIN and COUT ● Extraction >> and insertion << operator ● endl vs n ● Code Runner(Extension) issue with CIN
  • 11. Comments in C++ 11 ● SIngle Line Comment -// ● Multiline Comment - /* */
  • 12. 12 Variables & Data Types in C++
  • 13. 13 Rules for naming a variable ● Variable names in C++ can range from 1 to 255 characters. ● All variable names must begin with a letter of the alphabet or an underscore(_). ● After the first initial letter, variable names can also contain letters and numbers. ● Variable names are case sensitive. ● No spaces or special characters are allowed. ● You cannot use a C++ keyword (a reserved word) as a variable name.
  • 14. 14
  • 16. 16 Data Type Size Value Range int 4 Bytes -2147483648 to 2147483647 char 1 Bytes -127 to 127 or 0 to 255 float 4 Bytes - 3.4E38 to 3.4E38 double 8 Byte - 1.7E308 to 1.7E + 308 bool 1 Byte
  • 17. Modifiers in c++ 17 ● Signed ● unsigned ● short ● long
  • 18. 18 Data Type Size Value Range int 4 Bytes -2147483648 to 2147483647 Unsigned int 4 Bytes 0 to 4294967295 signed int 4 Bytes -2147483648 to 2147483647 Sort int 2 Bytes -32768 to 32767 long int 8 Bytes -2,147,483,648 to 2,147,483,647 char 1 Bytes -127 to 127 or 0 to 255 Unsigned char 1 Bytes 0 to 255 Signed char 1 Byte -127 to 127 float 4 Bytes - 3.4E38 to 3.4E38 double 8 Byte - 1.7E308 to 1.7E + 308 long double 12 Bytes - 3.4E4932 to 1.1E + 4932 bool 1 Byte
  • 19. Scope of Variables in C++ ● Local Variables ● Global Variables
  • 20. Constant Variables ● A const variable must be assigned a value at the time of its declaration. ● If we declare a variable as const, we cannot change its value. ● Once initialized, if we try to change its value, then we will get compilation error. 20
  • 21. Manipulators in c++ 21 Manipulator Purpose Header File endl causes line feed to be inserted i.e. ‘n’ iostream.h dec,oct,hex set the desired number system iostream.h setbase (b) output integers in base b iomanip.h setw(w) read or write values to w characters iomanip.h setfill (c) fills the whitespace with character c iomanip.h setprecision(n) set floating point precision to n iomanip.h
  • 22. Operators in C++ 1. Arithmetic Operators 2. Relational Operators 3. Logical Operators 4. Assignment Operators 5. Bitwise Operators 6. Other Operators 22
  • 24. 24 Arithmetic Operators Operator Description Example + Adds two operands A+B=30 - Subtracts second operand from the first A-B=10 * Multiplies both operands A*B=200 / Divides numerator by de-numerator A/B=2 % Modulus operator – the result is the remainder of the division A%B=0 ++ Increment operator, increases integer value by one A++ will give 21 -- Decrement operator, decreases integer value by one B-- will give 9 Assume A=20 and B=10
  • 25. 25 Relational Operators Operator Description Example == Checks if the values of two operands are equal or not. (A == B) = false != Checks if the values of two operands are equal or not. (A != B) = true > Checks if the value of left operand is greater than the value of right operand (A>B) = true < Checks if the value of left operand is less than the value of right operand, (A<B) = false >= Checks if the value of left operand is greater than or equal to the value of right operand (A>=B) = true <= Checks if the value of left operand is less than or equal to the value of right operand (A<=B) = false Assume A=20 and B=10
  • 26. 26 Logical Operators Operator Description Example && Logical AND. True only if all the operands are true. (A>10 && B>20) = false || Logical OR. True if at least one of the operands is true. (A>10 || B>20) = true ! Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true, then Logical NOT operator will make false. !(A>10) = false Assume A=20 and B=10
  • 27. 27 Logical Operators A B A && B A|| B !A false false false false true false true false true true true false false true false true true true true false
  • 28. 28 Assignment Operators Operator Description Example = Assigns values from right side operands to left side operand. A =5 += It adds right operand to the left operand and assign the result to left operand A +=5 same as A=A+5 -= It subtracts right operand from the left operand and assign the result to left operand. A-=5 same as A=A-5 *= It multiplies right operand with the left operand and assign the result to left operand. A*=5 same as A=A*5 /= It divides left operand with the right operand and assign the result to left operand. A/=5 same as A=A/5 %= It takes modulus using two operands and assign the result to left operand. A%=5 same as A=A%5
  • 29. 29 Bitwise Operators A B A&B A|B A^B ~A 0 0 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0
  • 30. 30 Bitwise Operators Operator Description Example & Binary AND Operator copies a bit to the result if it exists in both operands. (A & B) = 1 (00000001) | Binary OR Operator copies a bit if it exists in either operand. (A | B) = 3 (00000011) ^ Binary XOR Operator copies the bit if it is set in one operand but not both. (A ^ B) = 2 (00000010) ~ Binary Ones Complement Operator is unary and has the effect of 'flipping' bits. !A=!3= -4 (11111100) << Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. A<<1 = 6 (00000110) >> Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. A>>1 = 1 (00000001) A=3 (0000 0011 ) and B=1 (0000 0001)
  • 31. 31 Other Operators Operator Description Example sizeof Returns the size of variable sizeof(int) =4 Condition ? x:y If condition is true then it returns value of X otherwise returns value of Y Int y=20; int x= (y < 10) ? 30 : 40; cast Convert one data type to other int(2.2000) = 2 , causes a sequence of operations to be performed. The value of the entire comma expression is the value of the last expression of the comma-separated list. Int j=1; int i= (j++, j+10, j+20); & Returns the address of a variable * Is pointer to a variable
  • 32. 32 Operators Precedence and Associativity Category Operator Associativity Postfix () [] -> . ++ - - Left to right Unary + - ! ~ ++ - - (type)* & sizeof Left to right Multiplicative * / % Left to right Additive + - Left to right Shift << >> Left to right Relational < <= > >= Left to right Equality == != Left to right Bitwise AND & Left to right
  • 33. 33 Operators Precedence and Associativity Category Operator Associativity Bitwise XOR ^ Left to right Bitwise OR | Left to right Logical AND && Left to right Logical OR || Left to right Conditional ?: Right to left Assignment = += -= *= /= %=>>= <<= &= ^= |= Right to left Comma , Left to right
  • 34. Increment (++) and decrement (--) 34 1. The increment operator ++ increases the value of a variable by 1 2. Similarly, the decrement operator -- decreases the value of a variable by 1 3. Increment and decrement operators can be used only with variables. They can't be used with constants or expressions. Eg. x=5,y=6; x++; // valid 5++; // invalid (x+y)++; // invalid
  • 35. Types of Increment ++ operator 35 Increment ++ Post-increment Eg. a++ Pre-increment Eg. ++a 1. In pre-increment first increment the value of variable and then used inside the expression (initialize into another variable). 2. In post-increment first value of variable is use in the expression (initialize into another variable) and then increment the value of variable.
  • 36. Types of decrement -- operator 36 decrement -- Post-decrement Eg. a-- Pre-decrement Eg. --a 1. In pre-decrement first decrement the value of variable and then used inside the expression (initialize into another variable). 2. In post-decrement first value of variable is use in the expression (initialize into another variable) and then decrement the value of variable.
  • 37. 37 ● If-else ● Switch ● For Loop ● While loop ● Do-While Loop ● Break /Continue ● Goto Control Statement
  • 38. 38 ● If statement ● If...else statement ● If…else if…else statement ● Nested if statement If-else
  • 39. 39 ● Write a C++ program to accept two integers and check whether they are equal or not. ● Write a C++ program to accept a integer and check whether number is even or odd. ● Write a C++ program to accept a integer and check whether number is positive,negative or zero. ● Write a program in C++ to read any day number in integer and display day name in the word. ● Write a C++ program to accept two integers and find maximum between two numbers. If-else practice questions :
  • 41. 41 Switch-case practice questions : ● Write a C++ program to print day of week name using switch case. ● Write a C++ program print total number of days in a month using switch case. ● Write a C++ program to accept a integer and check whether number is positive,negative or zero using switch case. ● Write a program in C++ to read any day number in integer and display day name in the word using switch case.
  • 42. 42 Loops in C++ : ● For loop ● While loop ● Do-while loop
  • 43. 43 For loop : Syntax : for(initialization;condition;increment){ // your code } Example: for(int i=0;i<5;i++){ cout<<i<<”n”; }
  • 44. 44 While loop : Syntax : while(condition){ // your code } Example: int i=0; while(i<10){ cout<<i<<”n”; i++; }
  • 45. 45 do-while loop : Syntax : do{ // your code }while(condition) Example: int i=0; do{ cout<<i<<”n”; i++; }while(i<10)
  • 46. 46 Loop practice questions : ● Write a program in C++ to find the first 10 natural numbers ○ 1 2 3 4 5 6 7 8 9 10 ● Write a program in C++ to print a square pattern with # character. ● Write a program in C++ to find the factorial of a number. ● Write a program in C++ to display the pattern like right angle triangle using an asterisk.
  • 47. 47 Loop practice questions : ● Write a program in C++ to display the pattern like right angle triangle using an asterisk. ● Write a program in C++ to make such a pattern like a pyramid with an asterisk.
  • 48. 48 Break ● In C++, the break statement terminates the loop when it is encountered.
  • 49. 49 Continue ● In C++, the continue is used to skip the current iteration of the loop and the control of the program goes to the next iteration
  • 51. C++ Functions 51 ● A function is a block of code that performs a specific task. ● Functions help us in reducing code redundancy. ● If functionality is performed at multiple places in software, then rather than writing the same code, again and again, we create a function and call it everywhere. ● This also helps in maintenance as we have to change at one place if we make future changes to the functionality.
  • 52. C++ Functions 52 ● There are two types of function: ○ Library Functions (Built in functions) ○ User defined functions ● Function declaration returnType functionName (parameter1, parameter2,...) { // function body }
  • 53. Function Prototype 53 ● The code of function declaration should be before the function call. ● However, if we want to define a function after the function call, we need to use the function prototype. ● Function prototype is a declaration statement. type function-name (arguments-list); Eg. int sum(int num1,int num2); OR int sum(int,int); // Variable name is optional
  • 54. Default Parameters 54 ● In C++, we can provide default values for function parameters. ● In this case, when we invoke the function, we don’t specify parameters. ● Instead, the function takes the default parameters that are provided in the prototype. ● Note that while providing default parameters, we always start from the right-most parameter. Also, we cannot skip a parameter in between and provide a default value for the next parameter. ● Eg. Void add(int x, int y, int z = 0) Default parameter
  • 55. Const Parameters 55 ● We can pass constant parameters to functions using the ‘const’ keyword. ● When a parameter or reference is const, it cannot be changed inside the function. Void add(const x, const y) Const parameter
  • 56. Inline Functions 56 ● When we make a function call, internally it involves a compiler storing the state of the program on a stack before passing control to the function. ● When the function returns, the compiler has to retrieve the program state back and continue from where it left. ● This poses an overhead. Hence, in C++ whenever we have a function consisting of few statements, there is a facility that allows it to expand inline. ● This is done by making a function inline. So inline functions are the functions that are expanded at runtime, saving the efforts to call the function and do the stack modifications.
  • 57. Inline Functions 57 ● But even if we make a function as inline, the compiler does not guarantee that it will be expanded at runtime. ● In other words, it’s completely dependent on the compiler to make the function inline or not. ● Eg. inline int addition(const int a,const int b)