SlideShare a Scribd company logo
Amanpal Singh Rayat
*
*
*The character set of C represents alphabet,
digit or any symbol used to represent
information.
Types Character Set
Uppercase Alphabets A, B, C, … Y, Z
Lowercase Alphabets a, b, c, … y, z
Digits 0, 1, 2, 3, … 9
Special Symbols
~ ‘ ! @ # % ^ & * ( ) _ - + = |  {
} [ ] : ; " ' < > , . ? /
White spaces Single space, tab, new line.
*
*Smallest unit in a program/statement.
*It makes the compiler understand what is written in the
program.
*Example: main, printf , name,), etc.
*Tokens are broadly classified as:
*Identifiers
*Keywords
*Constants
*Variables
*Strings
*Operators
*Special character
*
*So to identify things we have some name given to them.
*Identifiers are the fundamental building blocks of a
program
*Used to give names to variables, functions, constant,
and user defined data.
*They are user-defined names and consist of a sequence
of letters and digits
*
An identifier name is any combination of 1 to 31
alphabets, digits or underscores.
The first character in the identifier name must
be an alphabet or underscore.
No blanks or special symbol other than an
underscore can be used in an identifier name.
Keywords are not allowed to be used as
identifiers.
*
*Keywords are the reserved words whose
meaning has already been explained to the C
compiler.
*We cannot use these keywords as variables.
*Each keyword is meant to perform a specific
function in a C program.
*There are 32 keywords in C language & 60 in
keywords in C++.
*All keywords are written in lowercase only
*
*
*
*Data type means the type of value a variable will have.
*It also defines memory space for a particular variable in
computer.
*The type of value of variable can be alphabets or
numbers.
*The numbers can be further divided as the integer or
rational number.
Data
Type
Basic Data Type
•Integer
•Character
•Float
•Double
Derived Data
Type
•Pointers
•Array
User Defined
Data Type
•Structure
•Union
•Enumeration
*
*
Type Size (in bytes)
16-bit complier
32 bit
compiler
Minimal range
char 1 1 -128 to 127
unsigned char 1 1 0 to 255
int 2 4 -32768 to 32767
unsigned int 2 4 0 to 65535
short int 2 4 -32768 to 32767
unsigned short
int
2 4 0 to 65535
long int 4 8 -2147483648 to 2147483647
unsigned long
int
4 8 0 to 4294967295
float 4 4 3.4e-38 to 3.4e+38 with 6 digits of
precision
double 8 8 1.7e-308 to 1.7e+308 with 15 digits of
precision
long double 10 10 3.4e-4932 to 1.1e+4932 with 20 digits of
precision
*
*Variable is an entity which may change.
*Variable is used to hold result and reserve memory for the
data.
datatype variable_name;
The naming of variable is done by following the same rules of
identifier naming.
*
1. An variable name is any combination of 1 to
31 alphabets, digits or underscores.
2. The first character in the variable name must
be an alphabet or underscore.
3. No blanks or special symbol other than an
underscore can be used in an variable name.
4. Keywords are not allowed to be used as
variables.
*
*The entity which do not change throughout the execution are
called constants.
*Types of constants:
*Integer constant
*Character constant
*Floating point constants
*String constants
*
*Expressions are the statements or the instruction given to
computer to perform some operation.
*Every expression results in some value that can be stored in
a variable.
*Following are few example of expressions in program:
*Expression to calculate speed of a car.
*Speed=distance/time
*Expression to find similarity of two things.
*c=value1>value2
*Expressions in C are basically operators acting on operands.
*An operand is an entity on which operation is to be
performed.
*An operator specifies the operation to be applied on
operands.
*Expressions are made of one or more operands.
*Statements like :
a = b + c,
++z
300 > (8 * k)
*
*Types of operators are:
1. Arithmetic operator
2. Unary operator
3. Relational operator
4. Logical operator
5. Assignment operator
6. Conditional operator
7. Bitwise operator
8. Special operator
*
Arithmetic Operators
These are binary operators i.e. expression requires two
operands
Operator Description Example (a=4 and b=2)
+ Addition of two operands a + b = 6
- Subtraction of two operands a – b = 2
* Multiplication of two operands a * b = 8
/ Division of two operands a / b = 2
% Modulus gives the remainder
after division of two operands
a % b = 0
Unary Operator
These operator requires only one operand.
Operator Description Example(count=1)
+ unary plus is used to show
positive value
+count; value is 1
- unary minus negates the value
of operand
-count; value is -1
++ Increment operator is used to
increase the operand value by 1
++count; value is 2
count++; value is 2
-- Decrement operator is used to
decrease the operand value by 1
--count; value is 1
count--; value is 1
Relational Operator
It compares two operands depending upon the their relation.
Expression generates zero(false) or nonzero(true) value.
Operator Description Example (a=10
and b=20)
< less than, checks if the value of left operand is less than
the value of right operand, if yes then condition becomes
true.
(a < b) value is
1(true)
<= less than or equal to, checks if the value of left operand
is less than or equal to the value of right operand, if yes
then condition becomes true.
(a <= b) value is 1
(true).
> greater than, checks if the value of left operand is
greater than the value of right operand, if yes then
condition becomes true.
(a > b) value is 0 (not
true).
>= greater than or equal to, checks if the value of left
operand is greater than or equal to the value of right
operand, if yes then condition becomes true.
(a >= b) value is 1
(true).
== equality ,checks if the value of two operands is equal or
not, if yes then condition becomes true.
(a == b) value is 0
(not true).
!= inequality, checks if the value of two operands is equal or
not, if values are not equal then condition becomes true.
(a != b) value is 1
(true).
Logical Operator
It checks the logical relationship between two
expressions and the result is zero( false) or
nonzero(true).
Operator Description Example
&& Logical AND operator. If both the
operands are true then condition
becomes true.
(5>3 && 5<10) value
is 1 (true).
| | Logical OR Operator. If any of the two
operands is true then condition becomes
true.
(5>3 || 5<2) value is
1 (true).
! Logical NOT Operator. Use to reverses the
logical state of its operand. If a condition
is true then Logical NOT operator will
make false.
!(8==8) value is 0
(false).
Assignment Operator
They are used to assign the result of an expression on right side
to a variable on left side.
Operator Description Example(a=4 and b=2)
+= a=a+b a+=b; a=a+b = 6
-= a=a-b a-=b; a=a-b = 2
*= a=a*b a*=b; a=a*b = 8
/= a=a/b a/=b; a=a/b = 2
%= a=a%b a%=b; a=a%b = 0
>>= a=a>>b a=00000100 >> 2 = 00010000
<<= a=a<<b A=00000100 << 2 = 00000001
&= a=a&b (a=0100, b=0010) a&=b; a=a&b = 0000
|= a=a|b (a=0100, b=0010) a|=b; a=a|b =0110
^= a=a^b (a=0100, b=0010) a^=b; a=a^b = 0110
Conditional Operator
Conditional operator contains condition followed by two
statements. If the condition is true the first statement is
executed otherwise the second statement.
It is also called as ternary operator because it requires
three operands.
Operator Description Example
?: conditional expression,
Condition? Expression1:
Expression2
(a>b)?cout<<a: cout<<b;
Bitwise Operator
A bitwise operator works on each bit of data.
Operato
r
Description Example(a=1
and b=0)
& bitwise AND a & b = 0
| bitwise OR a| b = 1
^ bitwise XOR a ^ b = 1
~ bitwise one’s
complement
~a = 0, ~b=1
<< bitwise left shift,
indicates the bits
are to be shifted to
the left.
1101 << 1 = 1010
>> bitwise right shift,
indicates the bits
are to be shifted to
the right.
1101 >> 1 = 0110
Logical Table
a b a & b a | b a ^
b
0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1
Some Special Operators
Operato
r
Description Example
, comma operator, can be used to
link the related expressions
together
int a, b, x;
sizeof () sizeof operator to find the size of
an object.
int a; sizeof(a)=2
type Cast operator, to change the data
type of the variable
float x= 12.5;
int a;
a = (int) x; value of a is
12.
*
*The precedence of operators determine a rank for the
operators. The higher an operator's precedence or priority,
the higher “binding”it has on the operands.
Example: So how the expression a * b + c will be interpreted?
(a * b) + c or a * (b + c),
here the first interpretation is the one that is used because the
multiplication operator has higher precedence than addition.
*
*Associativity tell us the order in which several operators
with equal precedence are computed or processed in
two directions, either from left to right or vice-versa.
Example: In the expression
a * b / c,
since multiplication and division have the same precedence we must
use the associativity to determine the grouping. These operators are
left associative which means they are grouped left to right as if the
expression was
(a * b) / c.
*
Precedence Operator Associativity Type
1 () [] . -> ++(postfix) - - (postfix) left to right Highest
2 + - ++ -- ! & * ~ sizeof (type) right to left Unary
3 * / % left to right multiplicative
4 + - left to right additive
5 << >> left to right shifting
6 < <= > >= left to right relational
7 == != left to right equality
8 & left to right bitwise AND
9 ^ left to right bitwise OR
10 | left to right bitwise OR
11 && left to right logical AND
12 || left to right logical OR
13 ?: right to left conditional
14 = += -= *= /= &= |= ^= <<= >>= %= right to left assignment
15 , left to right comma
*
// sample C++ program
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, there!";
return 0;
}
2-28
comment
preprocessor
directive
which namespace
to use
beginning of
function named main
beginning of
block for main
output
statement
string
literal
send 0 to
operating system
end of block
for main

More Related Content

PPTX
PPTX
Variable, constant, operators and control statement
PDF
Python : basic operators
PPTX
Operators in Python
PDF
C++ Expressions Notes
PPTX
Operators in python
PDF
Chapter 5 - Operators in C++
Variable, constant, operators and control statement
Python : basic operators
Operators in Python
C++ Expressions Notes
Operators in python
Chapter 5 - Operators in C++

What's hot (19)

DOCX
Data types and operators in vb
PDF
Operators in python
PPTX
Operators in c++
PPT
Operation and expression in c++
PPTX
Python Operators
PPTX
Python Training in Bangalore | Python Operators | Learnbay.in
PPTX
Python operators
PPT
C Sharp Jn (2)
PDF
Operators in python
PPT
Operator & Expression in c++
PPTX
Operator.ppt
DOCX
Basics of c++
PDF
Java basic operators
PPT
PPTX
Operators and Expressions
PPTX
Programming presentation
PPTX
Lecture 2 C++ | Variable Scope, Operators in c++
PPT
Operators and Expressions in C++
PPTX
Variables, Data Types, Operator & Expression in c in detail
Data types and operators in vb
Operators in python
Operators in c++
Operation and expression in c++
Python Operators
Python Training in Bangalore | Python Operators | Learnbay.in
Python operators
C Sharp Jn (2)
Operators in python
Operator & Expression in c++
Operator.ppt
Basics of c++
Java basic operators
Operators and Expressions
Programming presentation
Lecture 2 C++ | Variable Scope, Operators in c++
Operators and Expressions in C++
Variables, Data Types, Operator & Expression in c in detail
Ad

Similar to C++ revision add on till now (20)

PDF
Types of Operators in C
PPTX
data type.pptxddddswwyertr hai na ki extend kr de la
PPTX
Python programming language introduction unit
PPTX
Operators and it's type
PDF
Coper in C
PPTX
3. C_OperatorsExpressions on c languyage.pptx
PPTX
Operators and expressions in C++
PDF
C++ notes.pdf BASIC C++ NOTES FOR BEGGINERS
PPTX
Chapter 3.3
PDF
SPL 6 | Operators in C
PPTX
C language basics
PPTX
This slide contains information about Operators in C.pptx
PPTX
btwggggggggggggggggggggggggggggggisop correct (1).pptx
PPT
PPT
Java - Operators
PPTX
Conditional and special operators
PPTX
Operators
PPT
C Sharp Jn (2)
PPT
6 operators-in-c
Types of Operators in C
data type.pptxddddswwyertr hai na ki extend kr de la
Python programming language introduction unit
Operators and it's type
Coper in C
3. C_OperatorsExpressions on c languyage.pptx
Operators and expressions in C++
C++ notes.pdf BASIC C++ NOTES FOR BEGGINERS
Chapter 3.3
SPL 6 | Operators in C
C language basics
This slide contains information about Operators in C.pptx
btwggggggggggggggggggggggggggggggisop correct (1).pptx
Java - Operators
Conditional and special operators
Operators
C Sharp Jn (2)
6 operators-in-c
Ad

Recently uploaded (20)

PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharma ospi slides which help in ospi learning
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Cell Structure & Organelles in detailed.
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
RMMM.pdf make it easy to upload and study
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharma ospi slides which help in ospi learning
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
TR - Agricultural Crops Production NC III.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Cell Structure & Organelles in detailed.
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPH.pptx obstetrics and gynecology in nursing
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Abdominal Access Techniques with Prof. Dr. R K Mishra
O5-L3 Freight Transport Ops (International) V1.pdf
O7-L3 Supply Chain Operations - ICLT Program
RMMM.pdf make it easy to upload and study
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Supply Chain Operations Speaking Notes -ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf

C++ revision add on till now

  • 2. * *The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A, B, C, … Y, Z Lowercase Alphabets a, b, c, … y, z Digits 0, 1, 2, 3, … 9 Special Symbols ~ ‘ ! @ # % ^ & * ( ) _ - + = | { } [ ] : ; " ' < > , . ? / White spaces Single space, tab, new line.
  • 3. * *Smallest unit in a program/statement. *It makes the compiler understand what is written in the program. *Example: main, printf , name,), etc. *Tokens are broadly classified as: *Identifiers *Keywords *Constants *Variables *Strings *Operators *Special character
  • 4. * *So to identify things we have some name given to them. *Identifiers are the fundamental building blocks of a program *Used to give names to variables, functions, constant, and user defined data. *They are user-defined names and consist of a sequence of letters and digits
  • 5. * An identifier name is any combination of 1 to 31 alphabets, digits or underscores. The first character in the identifier name must be an alphabet or underscore. No blanks or special symbol other than an underscore can be used in an identifier name. Keywords are not allowed to be used as identifiers.
  • 6. * *Keywords are the reserved words whose meaning has already been explained to the C compiler. *We cannot use these keywords as variables. *Each keyword is meant to perform a specific function in a C program. *There are 32 keywords in C language & 60 in keywords in C++. *All keywords are written in lowercase only
  • 7. * *
  • 8. * *Data type means the type of value a variable will have. *It also defines memory space for a particular variable in computer. *The type of value of variable can be alphabets or numbers. *The numbers can be further divided as the integer or rational number.
  • 9. Data Type Basic Data Type •Integer •Character •Float •Double Derived Data Type •Pointers •Array User Defined Data Type •Structure •Union •Enumeration *
  • 10. * Type Size (in bytes) 16-bit complier 32 bit compiler Minimal range char 1 1 -128 to 127 unsigned char 1 1 0 to 255 int 2 4 -32768 to 32767 unsigned int 2 4 0 to 65535 short int 2 4 -32768 to 32767 unsigned short int 2 4 0 to 65535 long int 4 8 -2147483648 to 2147483647 unsigned long int 4 8 0 to 4294967295 float 4 4 3.4e-38 to 3.4e+38 with 6 digits of precision double 8 8 1.7e-308 to 1.7e+308 with 15 digits of precision long double 10 10 3.4e-4932 to 1.1e+4932 with 20 digits of precision
  • 11. * *Variable is an entity which may change. *Variable is used to hold result and reserve memory for the data. datatype variable_name; The naming of variable is done by following the same rules of identifier naming.
  • 12. * 1. An variable name is any combination of 1 to 31 alphabets, digits or underscores. 2. The first character in the variable name must be an alphabet or underscore. 3. No blanks or special symbol other than an underscore can be used in an variable name. 4. Keywords are not allowed to be used as variables.
  • 13. * *The entity which do not change throughout the execution are called constants. *Types of constants: *Integer constant *Character constant *Floating point constants *String constants
  • 14. * *Expressions are the statements or the instruction given to computer to perform some operation. *Every expression results in some value that can be stored in a variable. *Following are few example of expressions in program: *Expression to calculate speed of a car. *Speed=distance/time *Expression to find similarity of two things. *c=value1>value2
  • 15. *Expressions in C are basically operators acting on operands. *An operand is an entity on which operation is to be performed. *An operator specifies the operation to be applied on operands. *Expressions are made of one or more operands. *Statements like : a = b + c, ++z 300 > (8 * k)
  • 16. * *Types of operators are: 1. Arithmetic operator 2. Unary operator 3. Relational operator 4. Logical operator 5. Assignment operator 6. Conditional operator 7. Bitwise operator 8. Special operator
  • 17. * Arithmetic Operators These are binary operators i.e. expression requires two operands Operator Description Example (a=4 and b=2) + Addition of two operands a + b = 6 - Subtraction of two operands a – b = 2 * Multiplication of two operands a * b = 8 / Division of two operands a / b = 2 % Modulus gives the remainder after division of two operands a % b = 0
  • 18. Unary Operator These operator requires only one operand. Operator Description Example(count=1) + unary plus is used to show positive value +count; value is 1 - unary minus negates the value of operand -count; value is -1 ++ Increment operator is used to increase the operand value by 1 ++count; value is 2 count++; value is 2 -- Decrement operator is used to decrease the operand value by 1 --count; value is 1 count--; value is 1
  • 19. Relational Operator It compares two operands depending upon the their relation. Expression generates zero(false) or nonzero(true) value. Operator Description Example (a=10 and b=20) < less than, checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. (a < b) value is 1(true) <= less than or equal to, checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. (a <= b) value is 1 (true). > greater than, checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. (a > b) value is 0 (not true). >= greater than or equal to, checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. (a >= b) value is 1 (true). == equality ,checks if the value of two operands is equal or not, if yes then condition becomes true. (a == b) value is 0 (not true). != inequality, checks if the value of two operands is equal or not, if values are not equal then condition becomes true. (a != b) value is 1 (true).
  • 20. Logical Operator It checks the logical relationship between two expressions and the result is zero( false) or nonzero(true). Operator Description Example && Logical AND operator. If both the operands are true then condition becomes true. (5>3 && 5<10) value is 1 (true). | | Logical OR Operator. If any of the two operands is true then condition becomes true. (5>3 || 5<2) value is 1 (true). ! Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false. !(8==8) value is 0 (false).
  • 21. Assignment Operator They are used to assign the result of an expression on right side to a variable on left side. Operator Description Example(a=4 and b=2) += a=a+b a+=b; a=a+b = 6 -= a=a-b a-=b; a=a-b = 2 *= a=a*b a*=b; a=a*b = 8 /= a=a/b a/=b; a=a/b = 2 %= a=a%b a%=b; a=a%b = 0 >>= a=a>>b a=00000100 >> 2 = 00010000 <<= a=a<<b A=00000100 << 2 = 00000001 &= a=a&b (a=0100, b=0010) a&=b; a=a&b = 0000 |= a=a|b (a=0100, b=0010) a|=b; a=a|b =0110 ^= a=a^b (a=0100, b=0010) a^=b; a=a^b = 0110
  • 22. Conditional Operator Conditional operator contains condition followed by two statements. If the condition is true the first statement is executed otherwise the second statement. It is also called as ternary operator because it requires three operands. Operator Description Example ?: conditional expression, Condition? Expression1: Expression2 (a>b)?cout<<a: cout<<b;
  • 23. Bitwise Operator A bitwise operator works on each bit of data. Operato r Description Example(a=1 and b=0) & bitwise AND a & b = 0 | bitwise OR a| b = 1 ^ bitwise XOR a ^ b = 1 ~ bitwise one’s complement ~a = 0, ~b=1 << bitwise left shift, indicates the bits are to be shifted to the left. 1101 << 1 = 1010 >> bitwise right shift, indicates the bits are to be shifted to the right. 1101 >> 1 = 0110 Logical Table a b a & b a | b a ^ b 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 1 0 0 1 1
  • 24. Some Special Operators Operato r Description Example , comma operator, can be used to link the related expressions together int a, b, x; sizeof () sizeof operator to find the size of an object. int a; sizeof(a)=2 type Cast operator, to change the data type of the variable float x= 12.5; int a; a = (int) x; value of a is 12.
  • 25. * *The precedence of operators determine a rank for the operators. The higher an operator's precedence or priority, the higher “binding”it has on the operands. Example: So how the expression a * b + c will be interpreted? (a * b) + c or a * (b + c), here the first interpretation is the one that is used because the multiplication operator has higher precedence than addition.
  • 26. * *Associativity tell us the order in which several operators with equal precedence are computed or processed in two directions, either from left to right or vice-versa. Example: In the expression a * b / c, since multiplication and division have the same precedence we must use the associativity to determine the grouping. These operators are left associative which means they are grouped left to right as if the expression was (a * b) / c.
  • 27. * Precedence Operator Associativity Type 1 () [] . -> ++(postfix) - - (postfix) left to right Highest 2 + - ++ -- ! & * ~ sizeof (type) right to left Unary 3 * / % left to right multiplicative 4 + - left to right additive 5 << >> left to right shifting 6 < <= > >= left to right relational 7 == != left to right equality 8 & left to right bitwise AND 9 ^ left to right bitwise OR 10 | left to right bitwise OR 11 && left to right logical AND 12 || left to right logical OR 13 ?: right to left conditional 14 = += -= *= /= &= |= ^= <<= >>= %= right to left assignment 15 , left to right comma
  • 28. * // sample C++ program #include <iostream> using namespace std; int main() { cout << "Hello, there!"; return 0; } 2-28 comment preprocessor directive which namespace to use beginning of function named main beginning of block for main output statement string literal send 0 to operating system end of block for main