SlideShare a Scribd company logo
By Fiaz Younas
 A program written in a high-level language is called
source code.
 Source code is also called Source program.
 Source code of high-level language is save with a
specific extension.
 For example the program written in c++ save with .ccp
extension.
#include<iostream> //preprocessor directives
Using namespace std; //std stand for symbols
int main() //main function
{
Cout<<“MY First c++ Program”;
System(“pause”);
}
 Compiler is a program that converts the instructions of
a high level language into machine language as a
whole.
 High-level language[Source code]:
 Machine Language[ Object Code]:
 Use the compiler to:
 Check the program that obey rules.
 Translate the program into machine language.
Source code Compiler Object code
 Compiler can translate the programs of only those
language for which it is written.
 For example c++ compiler can translate only those
program that are written in c++ language.
 The process of linking the library files with object
program is known as linking. These files accomplish
different task such as input output.
 A program that combines the object program with
additional library files is known as linker.
 This additional library files is used to create the
executable file whose extension is .exe .
 After compiling and linking the program file the new
file is created that is known as executable file.
 The process of running an executable file is known as
executing.
 The program must be loaded into main memory for
execution.
 A program that load the executable file into main
memory is known as loader.
Programming presentation
 A collection of rules for writing program in a
programming language is known as syntax.
 Basic structure of c++ program:
#include<iostream>
using namespace std;
int main()
{
Cout<<“Program body”;
System(“pause”);
}
 Define a set of values and a set of operation on those
values.
Category of c++ data types:
1. Simple data type
2. Structure data type
3. Pointer data type
Simple data type:
 A data type is called simple if variable of that type
can store only one value at a time. e.g. int a float b;
 Simple data type is building block of structure data
type.
 Integral:
integers (numbers without a decimal) e.g.
12,34 etc
 Floating-point:
decimal numbers e.g.12.34 ,45.5
 Enumeration type:
user-defined data type
Syntax of declare a variable and data type:
Datatype variable_name;
 int data type:
 Integers in C++, as in mathematics, are numbers such
as the following:
 -6728, -67, 0, 78, 36782, +763
Note the following two rules from these examples:
1. Positive integers do not need a + sign in front of them.
2. No commas are used within an integer. Recall that in
C++, commas are used to separate items in a list. So
36,782 would be interpreted as two integers: 36 and
782
Bool DATA TYPE:
 The data type bool has only two values : true and false.
 The central purpose of this data type is to manipulate
logical (Boolean) expressions.
Char DATA TYPE:
 The data type char is the smallest integral data type.
 It is mainly used to represent characters—that is,
letters, digits, and special symbols.
 e.g. 'A','a','0','*','+','$','&',''
 To deal with decimal numbers, C++ provides the
floating-point data type.
 It is also called real type data. It include positive and
negative values.
Types of Floating Point:
1. Float
2. Double
3. Long double
Data type Size in Bytes Description
Float 4 3.4 x10^-38 to 3.4 x10^+38
Double 8 1.7x10^-308 to1.7x10^+308
Long double 10 1.7x10^-4932 to1.7x10^+4932
Structure data type
 Each data item is a collection of other data items.
 E.g. array , structure , classes.
Pointer data type:
 The values belonging to pointer data types are the
memory addresses of your computer.
 pointer variables store memory addresses.
Syntax for pointer declaration:
dataType*variable;
 Operator are the symbols that are used to perform
certain operations on data.
C++ provides a variety of operators.
1. Arithmetic Operators
2. Relations Operations
3. Logical Operations
4. Assignments Operators
5. Increment and decrement Operators
6. Compound Assignment Operators
 Arithmetic operator is a symbol that performs
mathematical operation on data.
 C++ provides many arithmetic operators.
Operators Symbol Descriptions
Addition + Adds two values
Subtraction - Subtracts one from another
value
Multiplication * Multiplies two values
Division / Divides one by another
value
Modulus % Give the remainder of
division of tow integers
 Example if A=10 and B=5 then arithmetic operator and
results
Operation Result
A+B 15
A-B 5
A*B 50
A/b 2
A%B 0
 The relational operators are used to specify conditions
in program.
 A relational operators compare two values.
 Also called comparison operators.
C++ provides the following six relational operators with
their description:
 Greater than[>]:
Greater than operator returns true if the value on left
side of > greater than the value on the right side.
Otherwise returns false.
 Less than [<]:
Less than operator returns true if the value on left
side of < less than the value on the right side.
Otherwise returns false.
 Equal to ==:
Equal to operator returns true if the value on both
side of = equal. Otherwise returns false.
 Greater than or equal to [>=]:
Greater than or equal to operator returns true if the
value on left side of >= greater than or equal to the
value on the right side. Otherwise returns false.
 Less than or equal to [<=]:
Less than or equal to operator returns true if the
value on left side of <= less than or equal to the value
on the right side. Otherwise returns false.
 Not Equal to !=:
Not Equal to operator returns true if the value on left
side of != is not equal to the value on the right .
Otherwise returns false.
 Example if A=10 and B =5 the relational operator and
their result
Relational Expression Result
A>B True
A<B False
A<=B False
A>=B False
A==B False
A!=B True
 The Logical operators are used to evaluate compound
condition.
 Logical operators are as follows:
1. AND Operators(&&)
2. OR Operators(||)
3. NOT Operators(!)
1) AND Operators(&&)
The symbols used for AND operator is (&&).
 It is used to evaluate two condition.
 It produce result true if both condition is true.
 It produce result false if any of the condition is false.
Condition 1 Operator Condition 2 Result
False && False False
False && True False
True && False False
True && True True
Example:
 Suppose we have tow variables A=100 and B=50. the
compound condition (A>10) &&(B>10) is true .it
contain two conditions and both are true. So whole
compound condition is true.
 The compound condition (A>50) &&(B>50) is false. it
contain two conditions one is true and one is false. So
whole compound condition is false.
2) OR Operators(||)
The symbols used for OR operator is (||).
 It is used to evaluate two condition.
 It produce result true if any of the condition is true.
 It produce result false if both condition are false
Condition 1 Operator Condition 2 Result
False || False False
False || True True
True || False True
True || True True
 Example:
Suppose we have tow variables A=100 and B=50. the
compound condition (A>50) ||(B>50) is true .it contain
two conditions and one condition is true. So whole
compound condition is true.
 The compound condition (A>500) ||(B>500) is false. it
contain two conditions and both are false. So whole
compound condition is false.
3) NOT Operators(!)
 The symbol used for NOT is (!).
 It is used to reverse the result of a condition
 It produces true if the condition is false.
 It produces false if the condition is true.
Example:
 Suppose we have tow variables A=100 and B=50. the
condition !(A==B) is true .The result of (A==B) is false but
NOT operator converts it into true.
 The condition !(A>B) is false .The result of (A>B) is true
but NOT operator converts it into false.
 The assignment operator = is used in assignment
statement to assign a value or computational result to a
variable.
Syntax:
Variable_name= expression;
Variable_name it is the name of variable
= it the assignment operator
Expression it is any valid expression
; statement terminator
 The increment operator is used to increase the value of
variable by one.
 It is denoted by the symbol ++.
 The increment operator cannot increment the value of
constants and expressions.
 For example:
Valid statements Invalid statements
A++,x++ 10++
(a+b)++,or ++(a+b)
Forms of increment operator:
 Prefix
In prefix form ,the increment operator is written before
the variable as follows:
++y;
 Postfix
In postfix form ,the increment operator is written after
the variable as follows:
y++;
 Let A=++B and A=B++ are different:
In prefix: A=++B
 It increment the value of B by one.
 It assign the value of B to A.
++B;
A=B;
In postfix: A=B++
 It assign the value of B to A.
 It increment the value of B by one.
A=B;
++B;
 The decrement operator is used to decrease the value
of variable by one.
 It is denoted by the symbol --.
 The decrement operator cannot decrement the value
of constants and expressions.
 For example:
Valid statements Invalid statements
A--,x-- 10--
(a+b)--,or --(a+b)
Forms of decrement operator:
 Prefix
In prefix form ,the decrement operator is written before
the variable as follows:
--y;
 Postfix
In postfix form ,the decrement operator is written after
the variable as follows:
y--;
 Let A=--B and A=B--are different:
In prefix: A=--B
 It decrement the value of B by one.
 It assign the value of B to A.
--B;
A=B;
In postfix: A=B--
 It assign the value of B to A.
 It increment the value of B by one.
A=B;
--B;
 That combine assignment operator with arithmetic
operators.
 We are used to perform mathematical operator more
easily.
Syntax:
 Variable op=expression
 E.g. N+=10; is equalvent to N=N+10;
 The syntax of cout and << is:
 Called an output statement
 The stream insertion operator is <<
 Expression evaluated and its value is printed at the
current cursor position on the screen
 cin is used with >> to gather input
 The stream extraction operator is >>
 For example,
cin >>a;
 Causes computer to get a value of type int
 Places it in the variable a
 If statement
 If else statement
 If- else –if statement
 Nested if statement
 Switch case statement
 If is a decision-making statement.
 It is the simplest form of decision statement.
Syntax:
If(condition)
{
Statement1;
Statement2;
.
.
StatementN;
}
 Condition is given as relational expression.
 If the condition is true the statement or set of
statement is executed.
 If the condition is false the statement or set of
statement is not executed.
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
if(a>40)
cout<<"you are pass";
system("pause");
}
 It execute one block of statement when the condition it
true and the other if the condition is false.
 In any situation, one block is executed and the other
 Is skipped.
Syntax:
If(condition)
{
Statement(s);
}else
{
Statement(s);
}
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
if(a>40)
cout<<"you are pass";
else
cout<<"you are fail";
system("pause");
}
 Use to choose one block of statements from many
block of statements.
 It is used when there are many option and only one
block of statement should be executed on the basis of
a condition.
Syntax:
If(condition)
{
Block 1;
}
else if(condition)
{
Block2;
}
Else
{
Block N;
}
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"enter a number";
cin>>a;
if(a>0)
cout<<"the number is positive";
else if(a<0)
cout<<"the number is negative";
else
cout<<"the number is zero";
system("pause");
}
 An if statement within an if statement is called nested
if statement.
 In structure, the enter into the inner if only when the
outer condition is true.
 If the condition is false the control moves to the outer
part of the outer if and skipped the inner if statement.
Programming presentation
Programming presentation
 It is an alternative of nested if statement.
 It can be used easily when there are many choices available and only one should be executed.
Syntax:
Switch(expression)
{
case val 1:
Statements1;
break;
.
.
case val n:
Statements1;
break;
Default:
Statements1;
}
Programming presentation
LOOP:
 For Loop
 While Loop
 Do while Loop
 For loop execute one or more statement for a specified
number of times.
 Syntax:
For( intialization ; condition ; increment/decrement )
{
Statement(s);
}
 #include<iostream>
 using namespace std;
 int main()
 {
 int n;
 for(n=1;n<=5;n++)
 cout<<n<<endl;
 system("pause");
 }
 While loop executes one or more statement while the
given condition remain true.
 It is useful where the number of iterations is not know
in advance.
 Condition become before the body of loop.
 Syntax:
While(condition)
{
Statement(s);
}
#include<iostream>
using namespace std;
int main()
{
int n=1;
while(n<=5)
{
cout<<"Pakistan"<<endl;
n++;
}
system("pause");
}
 Do while loop executes one or more statement while the
given condition remain true.
 Important where a statement must be executed at least
once.
 Condition become after the body of loop.
Syntax
Do
{
Statement(s)
}
While(condition);
#include<iostream>
using namespace std;
int main()
{
int c=1;
do
{
cout<<c<<endl;
c++;
}
while(c<=10);
system("pause");
}

More Related Content

What's hot (19)

PDF
Chapter 5 - Operators in C++
Deepak Singh
 
PDF
Python Basic Operators
Soba Arjun
 
PPTX
Variables, Data Types, Operator & Expression in c in detail
gourav kottawar
 
PPTX
C++ revision add on till now
AmAn Singh
 
PPTX
Python Training in Bangalore | Python Operators | Learnbay.in
Learnbayin
 
PPTX
Expression and Operartor In C Programming
Kamal Acharya
 
PPTX
Python Operators
Adheetha O. V
 
PPT
CBSE Class XI :- Operators in C++
Pranav Ghildiyal
 
PPTX
Operators in Python
Anusuya123
 
PPTX
Operator.ppt
Darshan Patel
 
PPTX
Operators in C Programming
Jasleen Kaur (Chandigarh University)
 
PPT
C Prog. - Operators and Expressions
vinay arora
 
PPTX
Operators in c++
ABHIJITPATRA23
 
DOCX
C – operators and expressions
Chukka Nikhil Chakravarthy
 
PPTX
Python operators
SaurabhUpadhyay73
 
PPTX
Operators and expressions in C++
Neeru Mittal
 
PDF
C programming | Class 8 | III Term
Andrew Raj
 
PPTX
Operators
Then Murugeshwari
 
Chapter 5 - Operators in C++
Deepak Singh
 
Python Basic Operators
Soba Arjun
 
Variables, Data Types, Operator & Expression in c in detail
gourav kottawar
 
C++ revision add on till now
AmAn Singh
 
Python Training in Bangalore | Python Operators | Learnbay.in
Learnbayin
 
Expression and Operartor In C Programming
Kamal Acharya
 
Python Operators
Adheetha O. V
 
CBSE Class XI :- Operators in C++
Pranav Ghildiyal
 
Operators in Python
Anusuya123
 
Operator.ppt
Darshan Patel
 
Operators in C Programming
Jasleen Kaur (Chandigarh University)
 
C Prog. - Operators and Expressions
vinay arora
 
Operators in c++
ABHIJITPATRA23
 
C – operators and expressions
Chukka Nikhil Chakravarthy
 
Python operators
SaurabhUpadhyay73
 
Operators and expressions in C++
Neeru Mittal
 
C programming | Class 8 | III Term
Andrew Raj
 

Viewers also liked (20)

PPTX
Makerere university places of worship
amogin
 
PPTX
The good and bad about Makerere University
amogin
 
PPTX
Makerere university Challenges
A75
 
PPTX
makerere university
najib36
 
PPTX
THE BEAUTY AND THE BEAST IN MAKERERE UNIVERSITY
kushjulie
 
PPTX
Makerere University Powerpoint presentation
Timothy Atwiine
 
PPTX
La llorona
Hannah Larson
 
PDF
Презентация системы мониторинга и диспетчеризации (заметки)
Sergei Smalkov
 
PPT
La granja
sonidosdelosanimales
 
PDF
Clownaround pdf
aimperato
 
PDF
Bai giang thay_dinh_thanh_tung_full
tkkg92
 
DOCX
Galería mañana cultural
nathalydeniss
 
PPTX
Презентация территориально распределенной системы мониторинга и диспетчеризации
Sergei Smalkov
 
PPTX
Leonora 468
Hannah Eiden
 
PPT
22de dic2015 premios escuel adearte
extraescolares-Palencia
 
PPTX
Excursión Frómista, Carrión de los Condes
extraescolares-Palencia
 
PPTX
Makerere University
seerah
 
PPTX
Social ppt3
Yeon-Joon
 
ODP
Analysis sequences and bounded sequences
SANDEEP VISHANG DAGAR
 
PPTX
Presentation
Fiaz Khokhar
 
Makerere university places of worship
amogin
 
The good and bad about Makerere University
amogin
 
Makerere university Challenges
A75
 
makerere university
najib36
 
THE BEAUTY AND THE BEAST IN MAKERERE UNIVERSITY
kushjulie
 
Makerere University Powerpoint presentation
Timothy Atwiine
 
La llorona
Hannah Larson
 
Презентация системы мониторинга и диспетчеризации (заметки)
Sergei Smalkov
 
Clownaround pdf
aimperato
 
Bai giang thay_dinh_thanh_tung_full
tkkg92
 
Galería mañana cultural
nathalydeniss
 
Презентация территориально распределенной системы мониторинга и диспетчеризации
Sergei Smalkov
 
Leonora 468
Hannah Eiden
 
22de dic2015 premios escuel adearte
extraescolares-Palencia
 
Excursión Frómista, Carrión de los Condes
extraescolares-Palencia
 
Makerere University
seerah
 
Social ppt3
Yeon-Joon
 
Analysis sequences and bounded sequences
SANDEEP VISHANG DAGAR
 
Presentation
Fiaz Khokhar
 
Ad

Similar to Programming presentation (20)

PPT
C++ chapter 2
SHRIRANG PINJARKAR
 
PPTX
C++ revision add on till now
AmAn Singh
 
PPTX
additional.pptx
Yuvraj994432
 
PDF
Constructor and destructors
divyalakshmi77
 
PDF
section 2 c++. - section 2 c++- section 2 c++ -
IbrahimWael5
 
PDF
C++ notes.pdf BASIC C++ NOTES FOR BEGGINERS
AAFREEN SHAIKH
 
PPTX
C++ Programming Basics.pptx
ZntalemAbebe
 
PPTX
Csc240 -lecture_5
Ainuddin Yousufzai
 
PDF
Data types, operators and control structures unit-2.pdf
gurpreetk8199
 
PPT
FP 201 Unit 2 - Part 3
rohassanie
 
PPT
operators and expressions in c++
sanya6900
 
PPTX
Operators1.pptx
HARSHSHARMA840
 
PDF
2nd PUC Computer science chapter 5 review of c++
Aahwini Esware gowda
 
PPT
the new education support for software new
FarookMohamed12
 
PPTX
C++.pptx
Sabi995708
 
PPTX
POLITEKNIK MALAYSIA
Aiman Hud
 
PPTX
object oriented programming presentation
Mahesh_gmail_KNL Na
 
PPTX
COM1407: C Operators
Hemantha Kulathilake
 
C++ chapter 2
SHRIRANG PINJARKAR
 
C++ revision add on till now
AmAn Singh
 
additional.pptx
Yuvraj994432
 
Constructor and destructors
divyalakshmi77
 
section 2 c++. - section 2 c++- section 2 c++ -
IbrahimWael5
 
C++ notes.pdf BASIC C++ NOTES FOR BEGGINERS
AAFREEN SHAIKH
 
C++ Programming Basics.pptx
ZntalemAbebe
 
Csc240 -lecture_5
Ainuddin Yousufzai
 
Data types, operators and control structures unit-2.pdf
gurpreetk8199
 
FP 201 Unit 2 - Part 3
rohassanie
 
operators and expressions in c++
sanya6900
 
Operators1.pptx
HARSHSHARMA840
 
2nd PUC Computer science chapter 5 review of c++
Aahwini Esware gowda
 
the new education support for software new
FarookMohamed12
 
C++.pptx
Sabi995708
 
POLITEKNIK MALAYSIA
Aiman Hud
 
object oriented programming presentation
Mahesh_gmail_KNL Na
 
COM1407: C Operators
Hemantha Kulathilake
 
Ad

Recently uploaded (20)

PPTX
declaration of Variables and constants.pptx
meemee7378
 
PPTX
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
PPTX
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
 
PPTX
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
PDF
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
PPTX
B2C EXTRANET | EXTRANET WEBSITE | EXTRANET INTEGRATION
philipnathen82
 
PDF
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
 
PPTX
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
PDF
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
PPT
Information Communication Technology Concepts
LOIDAALMAZAN3
 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
PDF
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
PPTX
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
 
PPTX
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
PDF
Building scalbale cloud native apps with .NET 8
GillesMathieu10
 
PDF
Automated Test Case Repair Using Language Models
Lionel Briand
 
PPTX
ManageIQ - Sprint 264 Review - Slide Deck
ManageIQ
 
declaration of Variables and constants.pptx
meemee7378
 
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
B2C EXTRANET | EXTRANET WEBSITE | EXTRANET INTEGRATION
philipnathen82
 
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
 
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
Information Communication Technology Concepts
LOIDAALMAZAN3
 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
 
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
Building scalbale cloud native apps with .NET 8
GillesMathieu10
 
Automated Test Case Repair Using Language Models
Lionel Briand
 
ManageIQ - Sprint 264 Review - Slide Deck
ManageIQ
 

Programming presentation

  • 2.  A program written in a high-level language is called source code.  Source code is also called Source program.  Source code of high-level language is save with a specific extension.  For example the program written in c++ save with .ccp extension.
  • 3. #include<iostream> //preprocessor directives Using namespace std; //std stand for symbols int main() //main function { Cout<<“MY First c++ Program”; System(“pause”); }
  • 4.  Compiler is a program that converts the instructions of a high level language into machine language as a whole.  High-level language[Source code]:  Machine Language[ Object Code]:  Use the compiler to:  Check the program that obey rules.  Translate the program into machine language. Source code Compiler Object code
  • 5.  Compiler can translate the programs of only those language for which it is written.  For example c++ compiler can translate only those program that are written in c++ language.
  • 6.  The process of linking the library files with object program is known as linking. These files accomplish different task such as input output.  A program that combines the object program with additional library files is known as linker.  This additional library files is used to create the executable file whose extension is .exe .
  • 7.  After compiling and linking the program file the new file is created that is known as executable file.  The process of running an executable file is known as executing.  The program must be loaded into main memory for execution.  A program that load the executable file into main memory is known as loader.
  • 9.  A collection of rules for writing program in a programming language is known as syntax.  Basic structure of c++ program: #include<iostream> using namespace std; int main() { Cout<<“Program body”; System(“pause”); }
  • 10.  Define a set of values and a set of operation on those values. Category of c++ data types: 1. Simple data type 2. Structure data type 3. Pointer data type Simple data type:  A data type is called simple if variable of that type can store only one value at a time. e.g. int a float b;  Simple data type is building block of structure data type.
  • 11.  Integral: integers (numbers without a decimal) e.g. 12,34 etc  Floating-point: decimal numbers e.g.12.34 ,45.5  Enumeration type: user-defined data type Syntax of declare a variable and data type: Datatype variable_name;
  • 12.  int data type:  Integers in C++, as in mathematics, are numbers such as the following:  -6728, -67, 0, 78, 36782, +763 Note the following two rules from these examples: 1. Positive integers do not need a + sign in front of them. 2. No commas are used within an integer. Recall that in C++, commas are used to separate items in a list. So 36,782 would be interpreted as two integers: 36 and 782
  • 13. Bool DATA TYPE:  The data type bool has only two values : true and false.  The central purpose of this data type is to manipulate logical (Boolean) expressions. Char DATA TYPE:  The data type char is the smallest integral data type.  It is mainly used to represent characters—that is, letters, digits, and special symbols.  e.g. 'A','a','0','*','+','$','&',''
  • 14.  To deal with decimal numbers, C++ provides the floating-point data type.  It is also called real type data. It include positive and negative values. Types of Floating Point: 1. Float 2. Double 3. Long double
  • 15. Data type Size in Bytes Description Float 4 3.4 x10^-38 to 3.4 x10^+38 Double 8 1.7x10^-308 to1.7x10^+308 Long double 10 1.7x10^-4932 to1.7x10^+4932
  • 16. Structure data type  Each data item is a collection of other data items.  E.g. array , structure , classes. Pointer data type:  The values belonging to pointer data types are the memory addresses of your computer.  pointer variables store memory addresses. Syntax for pointer declaration: dataType*variable;
  • 17.  Operator are the symbols that are used to perform certain operations on data. C++ provides a variety of operators. 1. Arithmetic Operators 2. Relations Operations 3. Logical Operations 4. Assignments Operators 5. Increment and decrement Operators 6. Compound Assignment Operators
  • 18.  Arithmetic operator is a symbol that performs mathematical operation on data.  C++ provides many arithmetic operators. Operators Symbol Descriptions Addition + Adds two values Subtraction - Subtracts one from another value Multiplication * Multiplies two values Division / Divides one by another value Modulus % Give the remainder of division of tow integers
  • 19.  Example if A=10 and B=5 then arithmetic operator and results Operation Result A+B 15 A-B 5 A*B 50 A/b 2 A%B 0
  • 20.  The relational operators are used to specify conditions in program.  A relational operators compare two values.  Also called comparison operators. C++ provides the following six relational operators with their description:  Greater than[>]: Greater than operator returns true if the value on left side of > greater than the value on the right side. Otherwise returns false.
  • 21.  Less than [<]: Less than operator returns true if the value on left side of < less than the value on the right side. Otherwise returns false.  Equal to ==: Equal to operator returns true if the value on both side of = equal. Otherwise returns false.  Greater than or equal to [>=]: Greater than or equal to operator returns true if the value on left side of >= greater than or equal to the value on the right side. Otherwise returns false.
  • 22.  Less than or equal to [<=]: Less than or equal to operator returns true if the value on left side of <= less than or equal to the value on the right side. Otherwise returns false.  Not Equal to !=: Not Equal to operator returns true if the value on left side of != is not equal to the value on the right . Otherwise returns false.
  • 23.  Example if A=10 and B =5 the relational operator and their result Relational Expression Result A>B True A<B False A<=B False A>=B False A==B False A!=B True
  • 24.  The Logical operators are used to evaluate compound condition.  Logical operators are as follows: 1. AND Operators(&&) 2. OR Operators(||) 3. NOT Operators(!) 1) AND Operators(&&) The symbols used for AND operator is (&&).  It is used to evaluate two condition.  It produce result true if both condition is true.  It produce result false if any of the condition is false.
  • 25. Condition 1 Operator Condition 2 Result False && False False False && True False True && False False True && True True
  • 26. Example:  Suppose we have tow variables A=100 and B=50. the compound condition (A>10) &&(B>10) is true .it contain two conditions and both are true. So whole compound condition is true.  The compound condition (A>50) &&(B>50) is false. it contain two conditions one is true and one is false. So whole compound condition is false.
  • 27. 2) OR Operators(||) The symbols used for OR operator is (||).  It is used to evaluate two condition.  It produce result true if any of the condition is true.  It produce result false if both condition are false Condition 1 Operator Condition 2 Result False || False False False || True True True || False True True || True True
  • 28.  Example: Suppose we have tow variables A=100 and B=50. the compound condition (A>50) ||(B>50) is true .it contain two conditions and one condition is true. So whole compound condition is true.  The compound condition (A>500) ||(B>500) is false. it contain two conditions and both are false. So whole compound condition is false.
  • 29. 3) NOT Operators(!)  The symbol used for NOT is (!).  It is used to reverse the result of a condition  It produces true if the condition is false.  It produces false if the condition is true. Example:  Suppose we have tow variables A=100 and B=50. the condition !(A==B) is true .The result of (A==B) is false but NOT operator converts it into true.  The condition !(A>B) is false .The result of (A>B) is true but NOT operator converts it into false.
  • 30.  The assignment operator = is used in assignment statement to assign a value or computational result to a variable. Syntax: Variable_name= expression; Variable_name it is the name of variable = it the assignment operator Expression it is any valid expression ; statement terminator
  • 31.  The increment operator is used to increase the value of variable by one.  It is denoted by the symbol ++.  The increment operator cannot increment the value of constants and expressions.  For example: Valid statements Invalid statements A++,x++ 10++ (a+b)++,or ++(a+b)
  • 32. Forms of increment operator:  Prefix In prefix form ,the increment operator is written before the variable as follows: ++y;  Postfix In postfix form ,the increment operator is written after the variable as follows: y++;
  • 33.  Let A=++B and A=B++ are different: In prefix: A=++B  It increment the value of B by one.  It assign the value of B to A. ++B; A=B; In postfix: A=B++  It assign the value of B to A.  It increment the value of B by one. A=B; ++B;
  • 34.  The decrement operator is used to decrease the value of variable by one.  It is denoted by the symbol --.  The decrement operator cannot decrement the value of constants and expressions.  For example: Valid statements Invalid statements A--,x-- 10-- (a+b)--,or --(a+b)
  • 35. Forms of decrement operator:  Prefix In prefix form ,the decrement operator is written before the variable as follows: --y;  Postfix In postfix form ,the decrement operator is written after the variable as follows: y--;
  • 36.  Let A=--B and A=B--are different: In prefix: A=--B  It decrement the value of B by one.  It assign the value of B to A. --B; A=B; In postfix: A=B--  It assign the value of B to A.  It increment the value of B by one. A=B; --B;
  • 37.  That combine assignment operator with arithmetic operators.  We are used to perform mathematical operator more easily. Syntax:  Variable op=expression  E.g. N+=10; is equalvent to N=N+10;
  • 38.  The syntax of cout and << is:  Called an output statement  The stream insertion operator is <<  Expression evaluated and its value is printed at the current cursor position on the screen
  • 39.  cin is used with >> to gather input  The stream extraction operator is >>  For example, cin >>a;  Causes computer to get a value of type int  Places it in the variable a
  • 40.  If statement  If else statement  If- else –if statement  Nested if statement  Switch case statement
  • 41.  If is a decision-making statement.  It is the simplest form of decision statement. Syntax: If(condition) { Statement1; Statement2; . . StatementN; }
  • 42.  Condition is given as relational expression.  If the condition is true the statement or set of statement is executed.  If the condition is false the statement or set of statement is not executed.
  • 43. #include<iostream> using namespace std; int main() { int a; cin>>a; if(a>40) cout<<"you are pass"; system("pause"); }
  • 44.  It execute one block of statement when the condition it true and the other if the condition is false.  In any situation, one block is executed and the other  Is skipped. Syntax: If(condition) { Statement(s); }else { Statement(s); }
  • 45. #include<iostream> using namespace std; int main() { int a; cin>>a; if(a>40) cout<<"you are pass"; else cout<<"you are fail"; system("pause"); }
  • 46.  Use to choose one block of statements from many block of statements.  It is used when there are many option and only one block of statement should be executed on the basis of a condition.
  • 48. #include<iostream> using namespace std; int main() { int a; cout<<"enter a number"; cin>>a; if(a>0) cout<<"the number is positive"; else if(a<0) cout<<"the number is negative"; else cout<<"the number is zero"; system("pause"); }
  • 49.  An if statement within an if statement is called nested if statement.  In structure, the enter into the inner if only when the outer condition is true.  If the condition is false the control moves to the outer part of the outer if and skipped the inner if statement.
  • 52.  It is an alternative of nested if statement.  It can be used easily when there are many choices available and only one should be executed. Syntax: Switch(expression) { case val 1: Statements1; break; . . case val n: Statements1; break; Default: Statements1; }
  • 54. LOOP:  For Loop  While Loop  Do while Loop
  • 55.  For loop execute one or more statement for a specified number of times.  Syntax: For( intialization ; condition ; increment/decrement ) { Statement(s); }
  • 56.  #include<iostream>  using namespace std;  int main()  {  int n;  for(n=1;n<=5;n++)  cout<<n<<endl;  system("pause");  }
  • 57.  While loop executes one or more statement while the given condition remain true.  It is useful where the number of iterations is not know in advance.  Condition become before the body of loop.  Syntax: While(condition) { Statement(s); }
  • 58. #include<iostream> using namespace std; int main() { int n=1; while(n<=5) { cout<<"Pakistan"<<endl; n++; } system("pause"); }
  • 59.  Do while loop executes one or more statement while the given condition remain true.  Important where a statement must be executed at least once.  Condition become after the body of loop. Syntax Do { Statement(s) } While(condition);
  • 60. #include<iostream> using namespace std; int main() { int c=1; do { cout<<c<<endl; c++; } while(c<=10); system("pause"); }