SlideShare a Scribd company logo
1 of 34
Download to read offline
Keywords, Identifiers ,
Datatypes
Unit-1
UGCA1909
Character Set
► As every language contains a set of characters used to construct words, statements, etc.,
► C++ language also has a set of characters which include alphabets, digits,
and special symbols. C++ language supports a total of 256 characters.
► C++ language character set contains the following set of characters...
1. Alphabets
2. Digits
3. Special Symbols
1.Alphabets
► C++ language supports all the alphabets from the English language. Lower and upper
case letters together support 52 alphabets.
► lower case letters - a to z
► UPPER CASE LETTERS - A to Z
2.Digits
► C++ language supports 10 digits which are used to construct numerical values in C
language.
► Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
3. Special Symbols
► C++ language supports a rich set of special symbols that include symbols to perform
mathematical operations, to check conditions, white spaces, backspaces, and other
special symbols.
► Special Symbols - ~ @ # $ % ^ & * ( ) _ - + = { } [ ] ; : ' " / ? . > , <  | tab
newline space NULL bell backspace verticaltab etc.,
C Tokens
► Every smallest individual unit of a c program is called token.
► Every instruction in a c program is a collection of tokens.
► Tokens are used to construct c++ programs and they are said to the basic
building blocks of a c++ program.
► In a c++ program tokens may contain the following...
► Keywords
► Identifiers
► Operators
► Special Symbols
► Constants
► Strings
► Data values
C Keywords
► Keywords are the reserved words with predefined meaning which already known to
the compiler.
► C++ programming also has words with a specific meaning which are used to construct c
program instructions.
► Keywords are also known as reserved words in C++ programming language.
► In the C++ programming language, there are 32 keywords.
Properties of Keywords
► All the keywords in C++ programming language are defined as lowercase
letters so they must be used only in lowercase letters
► Every keyword has a specific meaning, users can not change that meaning.
► Keywords can not be used as user-defined names like variable, functions,
arrays, pointers, etc...
► Every keyword in C++ programming language represents something or
specifies some kind of action to be performed by the compiler.
Keywords in C
C Identifiers
► The identifier is a user-defined name of an entity to identify it
uniquely during the program execution.
► An identifier is a collection of characters which acts as the name of variable,
function, array, pointer, structure, etc...
► Example
int marks;
Char c;
Float b;
Rules for Creating Identifiers
► An identifier can contain letters (UPPERCASE and lowercase), numeric &
underscore symbol only.
► An identifier should not start with a numerical value. It can start with a letter
or an underscore.
► We should not use any special symbols in between the identifier even
whitespace. However, the only underscore symbol is allowed.
► Keywords should not be used as identifiers.
► There is no limit for the length of an identifier. However, the compiler
considers the first 31 characters only.
► An identifier must be unique in its scope.
Rules for Creating Identifiers for better
programming
► The identifier must be meaningful to describe the entity.
► Since starting with an underscore may create conflict with system names, so
we avoid starting an identifier with an underscore.
► We start every identifier with a lowercase letter. If an identifier contains
more than one word then the first word starts with a lowercase letter and
second word onwards first letter is used as an UPPERCASE letter. We can also
use an underscore to separate multiple words in an identifier.
C++ data types
► Data types in the c programming language are used to specify what kind of
value can be stored in a variable.
► The memory size and type of the value of a variable are determined by the
variable data type.
► In a c program, each variable or constant or array must have a data type and
this data type specifies how much memory is to be allocated and what type of
values are to be stored in that variable or constant or array.
Types
► In the c programming language, data types are classified as follows...
► Primary data types (Basic data types OR Predefined data types)
► Derived data types (Secondary data types OR User-defined data types)
► Enumeration data types
► Void data type
DataTypes
Primary data types
► The primary data types in the C programming language are the basic data
types.
► All the primary data types are already defined in the system.
► Primary data types are also called as Built-In data types.
► The following are the primary data types in c programming language...
► Integer data type
► Floating Point data type
► Double data type
► Character data type
Integer Data type
► The integer data type is a set of whole numbers.
► Every integer value does not have the decimal value.
► We use the keyword "int" to represent integer data type in c++.
► We use the keyword int to declare the variables and to specify the return
type of a function.
► The integer data type is used with different type modifiers like short, long,
signed and unsigned.
The following table provides complete details about
the integer data type.
Floating Point data types
► Floating-point data types are a set of numbers with the decimal value. Every
floating-point value must contain the decimal value.
► The floating-point data type has two variants...
► float
► double
► We use the keyword "float" to represent floating-point data type and "double" to
represent double data type in c++.
► Both float and double are similar but they differ in the number of decimal places.
► The float value contains 6 decimal places whereas double value contains 15 or 19
decimal places.
floating-point data types
Character data type
► The character data type is a character enclosed in single quotations.
► The following table provides complete details about the character data type.
Other datatypes
► void data type
The void data type means nothing or no value. Generally, the void is used to specify a function which
does not return any value. We also use the void data type to specify empty parameters of a function.
► Enumerated data type
An enumerated data type is a user-defined data type that consists of integer constants and each integer
constant is given a name. The keyword "enum" is used to define the enumerated data type.
enum week{sunday, monday, tuesday, wednesday, thursday, friday, saturday};
enum week day;
► Derived data types
Derived data types are user-defined data types. The derived data types are also called as user-defined
data types or secondary data types. In the c++ programming language, the derived data types are
created using the following concepts...
► Arrays
► Structures
► Unions
► Enumeration
C++ Variables
► Variables in a c++ programming language are the named memory locations
where the user can store different values of the same datatype during the
program execution.
► That means a variable is a name given to a memory location in which we can
store different values of the same data type.
► In other words, a variable can be defined as a storage container to hold
values of the same datatype during the program execution.
► Declaration Syntax:
datatype variableName;
► Example
int number;
The above declaration tells to the compiler that allocates 2 bytes of memory with the
name number and allows only integer values into that memory location.
The following are the rules to specify a
variable name...
► A variable name may contain letters, digits and underscore symbol.
► Variable name should not start with a digit.
► Keywords should not be used as variable names.
► A variable name should not contain any special symbols except underscore(_).
► A variable name can be of any length but compiler considers only the first 31
characters of the variable name.
C Constants
► A constant is a named memory location which holds only one value throughout
the program execution.
► In C programming language, a constant is similar to the variable but the
constant hold only one value during the program execution.
► That means, once a value is assigned to the constant, that value can't be
changed during the program execution.
► Once the value is assigned to the constant, it is fixed throughout the program.
Types of Constants
Examples
► Integer constants
► An integer constant can be a decimal integer or octal integer or hexadecimal
integer.
► A decimal integer value is specified as direct integer value whereas octal integer
value is prefixed with 'o' and hexadecimal value is prefixed with 'OX’.
► Example
► 125 -----> Decimal Integer Constant
► O76 -----> Octal Integer Constant
► OX3A -----> Hexa Decimal Integer Constant
► Floating Point constants
► A floating-point constant must contain both integer and decimal parts. Some times
it may also contain the exponent part. When a floating-point constant is
represented in exponent form, the value must be suffixed with 'e' or 'E’.
► Example
► The floating-point value 3.14 is represented as 3E-14 in exponent form.
► Character Constants
► A character constant is a symbol enclosed in single quotation. A character constant has a
maximum length of one character.
► Example
► 'A'
► '2'
► '+’
► Escape sequences
► In the C++ programming language, there are some predefined character constants called
escape sequences. Every escape sequence has its own special functionality and every
escape sequence is prefixed with '' symbol. These escape sequences are used in cout.
► String Constants
► A string constant is a collection of characters, digits, special symbols and escape
sequences that are enclosed in double quotations.
► We define string constant in a single
► “Hello”
Creating constants in C++
► In a c programming language, constants can be created using two concepts...
► Using the 'const' keyword
► Using '#define' preprocessor
Using the 'const' keyword
► We create a constant of any datatype using 'const' keyword. To create a constant,
we prefix the variable declaration with 'const' keyword.
► The general syntax for creating constant using 'const' keyword is as follows...
► const datatype constantName ;
OR
► const datatype constantName = value ;
► Example
► const int x = 10 ;
► Here, 'x' is a integer constant with fixed value 10.
Example Program
#include<iostream.h>
#include<conio.h>
void main(){
int i = 9 ;
const int x = 10 ;
i = 15 ;
x = 100 ; // creates an error
cout<< “i=“<<i<<“n x=“<< x ;
}
Using '#define' preprocessor
► We can also create constants using '#define' preprocessor directive. When we create
constant using this preprocessor directive it must be defined at the beginning of the
program (because all the preprocessor directives must be written before the global
declaration).
► We use the following syntax to create constant using '#define' preprocessor
directive...
► #define CONSTANTNAME value
► Example
► #define PI 3.14
► Here, PI is a constant with value 3.14
Example Program
#include<iostream.h>
#include<conio.h>
#define PI 3.14
void main(){
int r, area ;
cout<<"Please enter the radius of circle : " ;
cin>>r;
area = PI * (r * r) ;
cout<<"Area of the circle “<<area ;
}
C++ Expressions
► In any programming language, if we want to perform any calculation or to
frame any condition etc., we use a set of symbols to perform the task. These
set of symbols makes an expression.
► An expression is a collection of operators and operands that represents a
specific value.
► In the above definition, an operator is a symbol that performs tasks like
arithmetic operations, logical operations, and conditional operations, etc.
► Operands are the values on which the operators perform the task.
► Example:
► c=a+b

More Related Content

What's hot

Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C ProgrammingKamal Acharya
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programmingKamal Acharya
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C v_jk
 
Tokens expressionsin C++
Tokens expressionsin C++Tokens expressionsin C++
Tokens expressionsin C++HalaiHansaika
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programmingprogramming9
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of ConstructorsDhrumil Panchal
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in CSahithi Naraparaju
 
What are variables and keywords in c++
What are variables and keywords in c++What are variables and keywords in c++
What are variables and keywords in c++Abdul Hafeez
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programmingHarshita Yadav
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and StringTasnima Hamid
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++rprajat007
 

What's hot (20)

Functions in C
Functions in CFunctions in C
Functions in C
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Tokens expressionsin C++
Tokens expressionsin C++Tokens expressionsin C++
Tokens expressionsin C++
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Strings in C
Strings in CStrings in C
Strings in C
 
C functions
C functionsC functions
C functions
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
What are variables and keywords in c++
What are variables and keywords in c++What are variables and keywords in c++
What are variables and keywords in c++
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
 
String functions in C
String functions in CString functions in C
String functions in C
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 

Similar to Keywords, identifiers ,datatypes in C++

Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageRai University
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c languageRai University
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageRai University
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageRai University
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c languageRai University
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.pptAqeelAbbas94
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiSowmyaJyothi3
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data typesPratik Devmurari
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
 
Visual Basic Fundamentals
Visual Basic FundamentalsVisual Basic Fundamentals
Visual Basic FundamentalsDivyaR219113
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
INTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxINTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxMamataAnilgod
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptxAnshSrivastava48
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 

Similar to Keywords, identifiers ,datatypes in C++ (20)

Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 
C presentation book
C presentation bookC presentation book
C presentation book
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
Constants variables data_types
Constants variables data_typesConstants variables data_types
Constants variables data_types
 
C
CC
C
 
Visual Basic Fundamentals
Visual Basic FundamentalsVisual Basic Fundamentals
Visual Basic Fundamentals
 
All C ppt.ppt
All C ppt.pptAll C ppt.ppt
All C ppt.ppt
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
INTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxINTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptx
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 

Recently uploaded

Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptxmary850239
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 

Recently uploaded (20)

Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 

Keywords, identifiers ,datatypes in C++

  • 2. Character Set ► As every language contains a set of characters used to construct words, statements, etc., ► C++ language also has a set of characters which include alphabets, digits, and special symbols. C++ language supports a total of 256 characters. ► C++ language character set contains the following set of characters... 1. Alphabets 2. Digits 3. Special Symbols
  • 3. 1.Alphabets ► C++ language supports all the alphabets from the English language. Lower and upper case letters together support 52 alphabets. ► lower case letters - a to z ► UPPER CASE LETTERS - A to Z 2.Digits ► C++ language supports 10 digits which are used to construct numerical values in C language. ► Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 3. Special Symbols ► C++ language supports a rich set of special symbols that include symbols to perform mathematical operations, to check conditions, white spaces, backspaces, and other special symbols. ► Special Symbols - ~ @ # $ % ^ & * ( ) _ - + = { } [ ] ; : ' " / ? . > , < | tab newline space NULL bell backspace verticaltab etc.,
  • 4. C Tokens ► Every smallest individual unit of a c program is called token. ► Every instruction in a c program is a collection of tokens. ► Tokens are used to construct c++ programs and they are said to the basic building blocks of a c++ program. ► In a c++ program tokens may contain the following... ► Keywords ► Identifiers ► Operators ► Special Symbols ► Constants ► Strings ► Data values
  • 5. C Keywords ► Keywords are the reserved words with predefined meaning which already known to the compiler. ► C++ programming also has words with a specific meaning which are used to construct c program instructions. ► Keywords are also known as reserved words in C++ programming language. ► In the C++ programming language, there are 32 keywords.
  • 6. Properties of Keywords ► All the keywords in C++ programming language are defined as lowercase letters so they must be used only in lowercase letters ► Every keyword has a specific meaning, users can not change that meaning. ► Keywords can not be used as user-defined names like variable, functions, arrays, pointers, etc... ► Every keyword in C++ programming language represents something or specifies some kind of action to be performed by the compiler.
  • 8. C Identifiers ► The identifier is a user-defined name of an entity to identify it uniquely during the program execution. ► An identifier is a collection of characters which acts as the name of variable, function, array, pointer, structure, etc... ► Example int marks; Char c; Float b;
  • 9. Rules for Creating Identifiers ► An identifier can contain letters (UPPERCASE and lowercase), numeric & underscore symbol only. ► An identifier should not start with a numerical value. It can start with a letter or an underscore. ► We should not use any special symbols in between the identifier even whitespace. However, the only underscore symbol is allowed. ► Keywords should not be used as identifiers. ► There is no limit for the length of an identifier. However, the compiler considers the first 31 characters only. ► An identifier must be unique in its scope.
  • 10. Rules for Creating Identifiers for better programming ► The identifier must be meaningful to describe the entity. ► Since starting with an underscore may create conflict with system names, so we avoid starting an identifier with an underscore. ► We start every identifier with a lowercase letter. If an identifier contains more than one word then the first word starts with a lowercase letter and second word onwards first letter is used as an UPPERCASE letter. We can also use an underscore to separate multiple words in an identifier.
  • 11. C++ data types ► Data types in the c programming language are used to specify what kind of value can be stored in a variable. ► The memory size and type of the value of a variable are determined by the variable data type. ► In a c program, each variable or constant or array must have a data type and this data type specifies how much memory is to be allocated and what type of values are to be stored in that variable or constant or array.
  • 12. Types ► In the c programming language, data types are classified as follows... ► Primary data types (Basic data types OR Predefined data types) ► Derived data types (Secondary data types OR User-defined data types) ► Enumeration data types ► Void data type
  • 14. Primary data types ► The primary data types in the C programming language are the basic data types. ► All the primary data types are already defined in the system. ► Primary data types are also called as Built-In data types. ► The following are the primary data types in c programming language... ► Integer data type ► Floating Point data type ► Double data type ► Character data type
  • 15.
  • 16. Integer Data type ► The integer data type is a set of whole numbers. ► Every integer value does not have the decimal value. ► We use the keyword "int" to represent integer data type in c++. ► We use the keyword int to declare the variables and to specify the return type of a function. ► The integer data type is used with different type modifiers like short, long, signed and unsigned.
  • 17. The following table provides complete details about the integer data type.
  • 18. Floating Point data types ► Floating-point data types are a set of numbers with the decimal value. Every floating-point value must contain the decimal value. ► The floating-point data type has two variants... ► float ► double ► We use the keyword "float" to represent floating-point data type and "double" to represent double data type in c++. ► Both float and double are similar but they differ in the number of decimal places. ► The float value contains 6 decimal places whereas double value contains 15 or 19 decimal places.
  • 20. Character data type ► The character data type is a character enclosed in single quotations. ► The following table provides complete details about the character data type.
  • 21. Other datatypes ► void data type The void data type means nothing or no value. Generally, the void is used to specify a function which does not return any value. We also use the void data type to specify empty parameters of a function. ► Enumerated data type An enumerated data type is a user-defined data type that consists of integer constants and each integer constant is given a name. The keyword "enum" is used to define the enumerated data type. enum week{sunday, monday, tuesday, wednesday, thursday, friday, saturday}; enum week day; ► Derived data types Derived data types are user-defined data types. The derived data types are also called as user-defined data types or secondary data types. In the c++ programming language, the derived data types are created using the following concepts... ► Arrays ► Structures ► Unions ► Enumeration
  • 22. C++ Variables ► Variables in a c++ programming language are the named memory locations where the user can store different values of the same datatype during the program execution. ► That means a variable is a name given to a memory location in which we can store different values of the same data type. ► In other words, a variable can be defined as a storage container to hold values of the same datatype during the program execution. ► Declaration Syntax: datatype variableName; ► Example int number; The above declaration tells to the compiler that allocates 2 bytes of memory with the name number and allows only integer values into that memory location.
  • 23. The following are the rules to specify a variable name... ► A variable name may contain letters, digits and underscore symbol. ► Variable name should not start with a digit. ► Keywords should not be used as variable names. ► A variable name should not contain any special symbols except underscore(_). ► A variable name can be of any length but compiler considers only the first 31 characters of the variable name.
  • 24. C Constants ► A constant is a named memory location which holds only one value throughout the program execution. ► In C programming language, a constant is similar to the variable but the constant hold only one value during the program execution. ► That means, once a value is assigned to the constant, that value can't be changed during the program execution. ► Once the value is assigned to the constant, it is fixed throughout the program.
  • 27. ► Integer constants ► An integer constant can be a decimal integer or octal integer or hexadecimal integer. ► A decimal integer value is specified as direct integer value whereas octal integer value is prefixed with 'o' and hexadecimal value is prefixed with 'OX’. ► Example ► 125 -----> Decimal Integer Constant ► O76 -----> Octal Integer Constant ► OX3A -----> Hexa Decimal Integer Constant ► Floating Point constants ► A floating-point constant must contain both integer and decimal parts. Some times it may also contain the exponent part. When a floating-point constant is represented in exponent form, the value must be suffixed with 'e' or 'E’. ► Example ► The floating-point value 3.14 is represented as 3E-14 in exponent form.
  • 28. ► Character Constants ► A character constant is a symbol enclosed in single quotation. A character constant has a maximum length of one character. ► Example ► 'A' ► '2' ► '+’ ► Escape sequences ► In the C++ programming language, there are some predefined character constants called escape sequences. Every escape sequence has its own special functionality and every escape sequence is prefixed with '' symbol. These escape sequences are used in cout. ► String Constants ► A string constant is a collection of characters, digits, special symbols and escape sequences that are enclosed in double quotations. ► We define string constant in a single ► “Hello”
  • 29. Creating constants in C++ ► In a c programming language, constants can be created using two concepts... ► Using the 'const' keyword ► Using '#define' preprocessor
  • 30. Using the 'const' keyword ► We create a constant of any datatype using 'const' keyword. To create a constant, we prefix the variable declaration with 'const' keyword. ► The general syntax for creating constant using 'const' keyword is as follows... ► const datatype constantName ; OR ► const datatype constantName = value ; ► Example ► const int x = 10 ; ► Here, 'x' is a integer constant with fixed value 10.
  • 31. Example Program #include<iostream.h> #include<conio.h> void main(){ int i = 9 ; const int x = 10 ; i = 15 ; x = 100 ; // creates an error cout<< “i=“<<i<<“n x=“<< x ; }
  • 32. Using '#define' preprocessor ► We can also create constants using '#define' preprocessor directive. When we create constant using this preprocessor directive it must be defined at the beginning of the program (because all the preprocessor directives must be written before the global declaration). ► We use the following syntax to create constant using '#define' preprocessor directive... ► #define CONSTANTNAME value ► Example ► #define PI 3.14 ► Here, PI is a constant with value 3.14
  • 33. Example Program #include<iostream.h> #include<conio.h> #define PI 3.14 void main(){ int r, area ; cout<<"Please enter the radius of circle : " ; cin>>r; area = PI * (r * r) ; cout<<"Area of the circle “<<area ; }
  • 34. C++ Expressions ► In any programming language, if we want to perform any calculation or to frame any condition etc., we use a set of symbols to perform the task. These set of symbols makes an expression. ► An expression is a collection of operators and operands that represents a specific value. ► In the above definition, an operator is a symbol that performs tasks like arithmetic operations, logical operations, and conditional operations, etc. ► Operands are the values on which the operators perform the task. ► Example: ► c=a+b