SlideShare a Scribd company logo
1 of 29
Programming
Fundamentals
Lecture#03
Delivered By:
Hassan iqbal
Superior College Toba Tek Singh
Basic Elements of a
C++ Program
Keywords:
 The predefined words of the C++ that are
used for special purposes in the source
program.
 Also known as reserved words
 Always written in lowercase
 There are 63 keywords in c++.
Tokens:
 In C++, a source program consists of
keywords, variables(or identifiers), constants,
operators, punctuators.
 These elements of a c++ program are called
tokens.
Identifier:
 The unique names used in the program to
represent the variables, constants, functions,
and labels etc. are called identifiers.
 The name of identifier may be 31 characters
long. If the name is more than 31 characters
long , then first 31 characters will be used by
the compiler.
 An identifier may:
 consist of alphabets, digits, and underscore.
 The first character of identifier name must be an
alphabetic letter or underscore.
 The keywords cannot be used as identifier
name.
Types of identifiers:
 Standard Identifier
 There are also predefined identifiers in c++
 The predefined identifiers that are used for
special purposes in the source program are
called the standard identifiers.
 E.g cin, cout
 User-defined identifier
 the identifiers defined by the user in the
program are called user-defined identifers.
 E.g variables, user-defined functions, labels
Data Types in C++:
 Data types specifies the type of the data
that a variable will hold.
 The data types defines the set of values
and set of operations on those values.
 Two categories:
 Standard Data Types
 The data types that are predefined as a part
of language.
 User defined Data Types
 The data types defined by the user
 The “int” data type:
Data Type
Name
Storage
capacity
Range
Int 2 bytes -32768 to 32767
Short int 2 bytes -32768 to 32767
Long int 4 bytes -2147483648 to
2147483647
Signed int Default Default
Unsigned int 2 bytes 0 to 65535
Unsigned long
int
4 bytes 0 to 4294967295
Real Type Data:
 The numeric values that have decimal
point in them are called real type data.
 Also known as floating point type data
 The real type data can be represented as
exponential notation i.e in terms of
mantissa and exponent.
 6432157.0 as 6.432157*10^6
 Where 6432157 is mantissa and 6 is the
exponent.
 As 6.432157E6
The “float” Data Type
Name Storage Capacity Range
Float 4 bytes 3.14*10−38
to
3.4*1038
Double 8 bytes 1.7*10−308 to
1.7*10308
Long double 10 bytes 3.14*10−4932
to
3.4*104932
The “char” data type:
 Used to store a single character such as
“a”, “$” etc.
 When the character is stored into a
variable, the ACII value is stored into the
variable.
 The ASCII value of ‘A’ is 65 and ‘a’ is 97.
 By default the character data type is
unsigned because the ASCII values are
positive.
 The range for unsigned ‘char’ data type is
from 0 to 255.
 For signed ‘char’ its -128 to127
Overflow and Underflow:
 An overflow occurs when the value
assigned to a variable is more than the
maximum allowable limit.
 An underflow occurs when the value
assigned to a variable is less then the
minimum allowable limit.
Variables:
 A quantity whose value may change
during program execution.
 Used to store program’s input data and
results during program execution.
 There are two basic operations that are
performed onto the variables.
 Declaration
 Initialization
Rules for Naming Variables:
 A variable name may consist of:
 Letter, digit, underscore
 The 1st character must be a letter or underscore.
 Special characters except underscore can’t be
used
 The keyword can’t be used as variable name
 Blank spaces are not allowed
 Length may be from 1 to 31 characters
 A variable name declared for one data type
can’t be used for another data type.
 Both uppercase and lowercase letters can be
used
 C++ is a case sensitive language.
 The meaningful name should be given to the
variable.
Constants:
 A quantity whose value does not change
during program execution
 Types:
 Literal constants
 Symbolic constants
Literal Constants:
 The word ‘literal’ means exact or
accurate.
 A literal is a constant having independent
value that is used in the program source
code.
 E.g 10,10.5, “excellent”
 Types:
 Integer Constant
 Integer constant must lie within the range of
the integer.
 The +ve and –ve signs can also be used.
 Floating-Point Constant:
 Letter ‘F’ or ‘L’ is used with the constant to
specify its data type.
 E.g 7.619F, 21.62L
 Character Constant:
 A single character enclosed in single
quotation marks.
 E.g ‘a’, ‘+’
 String Constant:
 A string of characters enclosed in double
quotation marks is known as string constant.
 E.g “abc”, “659329”
Symbolic Constants:
 is a constant identifer.
 Once a value is assigned to a symbolic
constant, it can’t be changed during
program execution.
 Can be declared in two ways:
 The ‘const’ keyword
 Using ‘define’ directive
 The ‘const’ keyword:
 Used to declare a constant identifier
 E.g const float pi=3.1417;
 The’ define’ directive:
 It’s a preprocessor directive
 Used to define a constant known as
constant macro
 A constant Macro is an identifier, which is
assigned a particular constant value
 Syntax:
 #define identifier expression
 # define pi 3.141593
Difference between define
and const
‘define’ directive ‘const’ Qualifier
Used as preprocessor
directive
Used as a statement
Not terminated with the ; Terminated with the ;
Data type of constant
identifier is not specified
Data type is specified
Operators and Expressions:
 operators are the special symbols that are
used to perform special operations on the
data.
 Arithmetic operators
 Increment and decrement operator
 Assignment operator
 Relational operator
 Logical operator
 The ‘sizeof’ operator
 Categories of operators:
 unary
 binary
Data Type of an Expression
Data types of operands Data type of expression
Int, float, long Float
int., long Long
Int, double, long double Long double
o Operators precedence:
o The order in which the arithmetic operators are
evaluated
o Without parenthesis:
o All multiplications and divisions first from left to
right first
o All additions and subtractions are then
performed from left to right
o Operators associativity:
o The order in which the operators of the same
precedence are evaluated
o For example in case of * and / operators, the
operations are performed from left to right
Operators Associativity
(), ++postfix, -- postfix Left to right
++ prefix, ++prefix Left to right
*,/,% Left to right
+,- Left to right
=,+=,-=,*=,/= Right to left
Assignment Statement
 A statement that is used to assign a value to a
variable.
 E.g c=a+b;
 Rvalue and Lvalue:
 The rvalue is an operand that can be written on
the right side of the assignment operator. It can
be a constant value, variable or na expression
 The lvalue is an operand that can be written on
the left side of the assignment operator.
 It must be a variable.
 Lvalue can be used as Rvalue but Rvalue
cannot be used as Lvalue.
 Compound assignment Statement:
 An assignment statement that is used to
assign the same value to many variables
 Also known as multiple assignment
statement
 Compound assignment operator
 Is a combination of arithmetic operator and
the assignment operator
Simple assignment
Statement
Assignment Statement using
Compound assignment
operator
X=x+12 X+=12
x=x-4 X-=4
X=x/3 x/=3
Increment and decrement operator:
Postfix, prefix
Type Casting
 Explicit type casting
 Cast operator
 (type) expression
int x;
x=(int) 3.156;
cout<<x;
 Implicit type casting
Comments:
 Single line
 Multi line
Programming Fundamentals
Programming Fundamentals

More Related Content

What's hot

Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programmingChitrank Dixit
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ LanguageWay2itech
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variableseShikshak
 
C data type format specifier
C data type format specifierC data type format specifier
C data type format specifierSandip Sitäulä
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2MOHIT TOMAR
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in cyash patel
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C ProgrammingQazi Shahzad Ali
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constantsvinay arora
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data typesPratik Devmurari
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operatorsraksharao
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGAbhishek Dwivedi
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programmingRumman Ansari
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programmingprogramming9
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data typesManisha Keim
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 

What's hot (20)

Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
 
C tokens
C tokensC tokens
C tokens
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
C Tokens
C TokensC Tokens
C Tokens
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
C data type format specifier
C data type format specifierC data type format specifier
C data type format specifier
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Data type in c
Data type in cData type in c
Data type in c
 
Constants variables data_types
Constants variables data_typesConstants variables data_types
Constants variables data_types
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
 
Pc module1
Pc module1Pc module1
Pc module1
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
C presentation book
C presentation bookC presentation book
C presentation book
 

Viewers also liked (7)

Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4
 
Chapter 3.1
Chapter 3.1Chapter 3.1
Chapter 3.1
 
Chap 2(const var-datatype)
Chap 2(const var-datatype)Chap 2(const var-datatype)
Chap 2(const var-datatype)
 
2. electric field calculation
2. electric field calculation2. electric field calculation
2. electric field calculation
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 

Similar to Programming Fundamentals

INTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxINTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxMamataAnilgod
 
Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# ProgrammingData Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# ProgrammingSherwin Banaag Sapin
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptxmadhurij54
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageRakesh Roshan
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic conceptsAbhinav Vatsa
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.pptFatimaZafar68
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centrejatin batra
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteTushar B Kute
 
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfIntroduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfAbrehamKassa
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++Aahwini Esware gowda
 
Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C languageSachin Verma
 
C++ Basics introduction to typecasting Webinar Slides 1
C++ Basics introduction to typecasting Webinar Slides 1C++ Basics introduction to typecasting Webinar Slides 1
C++ Basics introduction to typecasting Webinar Slides 1Ali Raza Jilani
 

Similar to Programming Fundamentals (20)

PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
INTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxINTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptx
 
Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# ProgrammingData Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# Programming
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
C material
C materialC material
C material
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
C keywords and identifiers
C keywords and identifiersC keywords and identifiers
C keywords and identifiers
 
C introduction
C introductionC introduction
C introduction
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.ppt
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfIntroduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++
 
C
CC
C
 
Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C language
 
C++ Basics introduction to typecasting Webinar Slides 1
C++ Basics introduction to typecasting Webinar Slides 1C++ Basics introduction to typecasting Webinar Slides 1
C++ Basics introduction to typecasting Webinar Slides 1
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

Programming Fundamentals

  • 2. Basic Elements of a C++ Program
  • 3. Keywords:  The predefined words of the C++ that are used for special purposes in the source program.  Also known as reserved words  Always written in lowercase  There are 63 keywords in c++. Tokens:  In C++, a source program consists of keywords, variables(or identifiers), constants, operators, punctuators.  These elements of a c++ program are called tokens.
  • 4. Identifier:  The unique names used in the program to represent the variables, constants, functions, and labels etc. are called identifiers.  The name of identifier may be 31 characters long. If the name is more than 31 characters long , then first 31 characters will be used by the compiler.  An identifier may:  consist of alphabets, digits, and underscore.  The first character of identifier name must be an alphabetic letter or underscore.  The keywords cannot be used as identifier name.
  • 5. Types of identifiers:  Standard Identifier  There are also predefined identifiers in c++  The predefined identifiers that are used for special purposes in the source program are called the standard identifiers.  E.g cin, cout  User-defined identifier  the identifiers defined by the user in the program are called user-defined identifers.  E.g variables, user-defined functions, labels
  • 6. Data Types in C++:  Data types specifies the type of the data that a variable will hold.  The data types defines the set of values and set of operations on those values.  Two categories:  Standard Data Types  The data types that are predefined as a part of language.  User defined Data Types  The data types defined by the user
  • 7.  The “int” data type: Data Type Name Storage capacity Range Int 2 bytes -32768 to 32767 Short int 2 bytes -32768 to 32767 Long int 4 bytes -2147483648 to 2147483647 Signed int Default Default Unsigned int 2 bytes 0 to 65535 Unsigned long int 4 bytes 0 to 4294967295
  • 8. Real Type Data:  The numeric values that have decimal point in them are called real type data.  Also known as floating point type data  The real type data can be represented as exponential notation i.e in terms of mantissa and exponent.  6432157.0 as 6.432157*10^6  Where 6432157 is mantissa and 6 is the exponent.  As 6.432157E6
  • 9. The “float” Data Type Name Storage Capacity Range Float 4 bytes 3.14*10−38 to 3.4*1038 Double 8 bytes 1.7*10−308 to 1.7*10308 Long double 10 bytes 3.14*10−4932 to 3.4*104932
  • 10. The “char” data type:  Used to store a single character such as “a”, “$” etc.  When the character is stored into a variable, the ACII value is stored into the variable.  The ASCII value of ‘A’ is 65 and ‘a’ is 97.  By default the character data type is unsigned because the ASCII values are positive.  The range for unsigned ‘char’ data type is from 0 to 255.  For signed ‘char’ its -128 to127
  • 11. Overflow and Underflow:  An overflow occurs when the value assigned to a variable is more than the maximum allowable limit.  An underflow occurs when the value assigned to a variable is less then the minimum allowable limit.
  • 12. Variables:  A quantity whose value may change during program execution.  Used to store program’s input data and results during program execution.  There are two basic operations that are performed onto the variables.  Declaration  Initialization
  • 13. Rules for Naming Variables:  A variable name may consist of:  Letter, digit, underscore  The 1st character must be a letter or underscore.  Special characters except underscore can’t be used  The keyword can’t be used as variable name  Blank spaces are not allowed  Length may be from 1 to 31 characters  A variable name declared for one data type can’t be used for another data type.  Both uppercase and lowercase letters can be used  C++ is a case sensitive language.  The meaningful name should be given to the variable.
  • 14. Constants:  A quantity whose value does not change during program execution  Types:  Literal constants  Symbolic constants
  • 15. Literal Constants:  The word ‘literal’ means exact or accurate.  A literal is a constant having independent value that is used in the program source code.  E.g 10,10.5, “excellent”  Types:  Integer Constant  Integer constant must lie within the range of the integer.  The +ve and –ve signs can also be used.
  • 16.  Floating-Point Constant:  Letter ‘F’ or ‘L’ is used with the constant to specify its data type.  E.g 7.619F, 21.62L  Character Constant:  A single character enclosed in single quotation marks.  E.g ‘a’, ‘+’  String Constant:  A string of characters enclosed in double quotation marks is known as string constant.  E.g “abc”, “659329”
  • 17. Symbolic Constants:  is a constant identifer.  Once a value is assigned to a symbolic constant, it can’t be changed during program execution.  Can be declared in two ways:  The ‘const’ keyword  Using ‘define’ directive
  • 18.  The ‘const’ keyword:  Used to declare a constant identifier  E.g const float pi=3.1417;  The’ define’ directive:  It’s a preprocessor directive  Used to define a constant known as constant macro  A constant Macro is an identifier, which is assigned a particular constant value  Syntax:  #define identifier expression  # define pi 3.141593
  • 19. Difference between define and const ‘define’ directive ‘const’ Qualifier Used as preprocessor directive Used as a statement Not terminated with the ; Terminated with the ; Data type of constant identifier is not specified Data type is specified
  • 20. Operators and Expressions:  operators are the special symbols that are used to perform special operations on the data.  Arithmetic operators  Increment and decrement operator  Assignment operator  Relational operator  Logical operator  The ‘sizeof’ operator  Categories of operators:  unary  binary
  • 21. Data Type of an Expression Data types of operands Data type of expression Int, float, long Float int., long Long Int, double, long double Long double
  • 22. o Operators precedence: o The order in which the arithmetic operators are evaluated o Without parenthesis: o All multiplications and divisions first from left to right first o All additions and subtractions are then performed from left to right o Operators associativity: o The order in which the operators of the same precedence are evaluated o For example in case of * and / operators, the operations are performed from left to right
  • 23. Operators Associativity (), ++postfix, -- postfix Left to right ++ prefix, ++prefix Left to right *,/,% Left to right +,- Left to right =,+=,-=,*=,/= Right to left
  • 24. Assignment Statement  A statement that is used to assign a value to a variable.  E.g c=a+b;  Rvalue and Lvalue:  The rvalue is an operand that can be written on the right side of the assignment operator. It can be a constant value, variable or na expression  The lvalue is an operand that can be written on the left side of the assignment operator.  It must be a variable.  Lvalue can be used as Rvalue but Rvalue cannot be used as Lvalue.
  • 25.  Compound assignment Statement:  An assignment statement that is used to assign the same value to many variables  Also known as multiple assignment statement  Compound assignment operator  Is a combination of arithmetic operator and the assignment operator
  • 26. Simple assignment Statement Assignment Statement using Compound assignment operator X=x+12 X+=12 x=x-4 X-=4 X=x/3 x/=3 Increment and decrement operator: Postfix, prefix
  • 27. Type Casting  Explicit type casting  Cast operator  (type) expression int x; x=(int) 3.156; cout<<x;  Implicit type casting Comments:  Single line  Multi line