SlideShare ist ein Scribd-Unternehmen logo
1 von 33
1. INTRODUCTION
2. CHARACTER SET
3. C TOKENS
4. DATA TYPES
Data Types and
Variables
Introduction
 The Sequence of the Instruction written to perform
specific task is called the Program.
 This Instructions are formed using special symbols
and words according to some rigid rule is known as
syntax rules.
 Every Instruction must be written according to the
syntax rule of the languages.
 Like any other languages C languages has its
vocabulary and grammar. They are follow up for
making the program.
Character Set
 Character Set is the set of the character.
 This characters are used to form the word, numbers
and expression.
 The characters in the c are grouped into the
following categories.
 Letters : Uppercase A…Z, Lowercase a…z
 Digits : All decimal digits 0 to 9
 Special Character : ,(comma) .(period) ; (semicolon) :(colon),
& (ampersand), # (number sign) etc.
 White spaces : Blank Space, Horizontal Space, New Line.
C Tokens
 Smallest Individual units are known as C Tokens.
 There are six types of the C Tokens.
 Keywords
 Identifiers
 Constants
 String
 Special Symbols
 Operators.
Keywords
 Every C word is classified as either keyword or
identifier.
 All keywords have fixed meanings and you can not
change its meanings.
 Keywords serve as a basic building blocks for
program statement. ANSI C supports 32 keywords.
 Ex: int, float, double, extern, static, auto, continue, if,
goto short, long etc. are the keywords
Identifiers
 Identifiers refer to the names of variables, functions
and arrays.
 These are user defined names and consists of
sequence of letters and digits.
 Both uppercase and lowercase letters are permitted
to make the identifier but generally lowercase letters
are used to make the variable.
Rules for Identifiers
 First character must be alphabet
 Must not contain white space
 Only first 31 characters are significant
 Can not use keyword as a identifier
Constants
 Constants referred as a fixed value that don't change
during the execution of the program.
 C Support Several types of constants:
 Numeric Constants
Integer constants
Real Constants
 Character Constants
Single Character Constants
String Constants
Integer Constants
 An integer constants refers as a sequence of digits.
 There are three types of integer constants.
 Decimal Integer
 Octal Integer
 Hexadecimal
Decimal Integer
 It consists of 0-9 digits, preceded by an optional – or
+ sign.
 Valid example of decimal integer are : 123 , -321, 0 ,
654321, +78
 Embedded spaces, comma and non digit characters
are not permitted between digits.
 15 750, 20,000, $1000 are Illegal
Octal Integer
 An Octal Integers consists of digits 0-7 with a leading
0.
 Example: 037, 0, 0435, 0551
Hexadecimal Integer
 A sequence of digits preceded by 0x or OX is
considered as Hexadecimal Integer.
 Hexadecimal Integer includes 0 to 9 digits and A to F
letters.
 Example: 0x9, 0x9F, OXBC etc are valid.
Real Constants
 Integer numbers are inadequate to represent
quantities such as distance, heights, temperature,
price and so on. These quantities are represented by
a number containing fractional parts like 12.32. Such
numbers are called real constants
 These numbers having a whole number followed by a
decimal digits.
 Example: 0.85, -0.75, 85.45, +241.54
 A real number may also be expressed in exponential
(Scientific) notation.
 General form :mantissa e exponent
 The mantissa is either a real number or integer
number.
 Exponent is an integer number with + or – sign.
 The letter e separating mantissa and exponent can be
written either in lowercase or in uppercase letter.
 Example : 215.65 may be written as 2.1565e2 in
exponential notation. e2 means multiple by 10^2
 75000 written as 7.5E4 or 7.5E+4
 -0.00038 written as -3.8e-4
 Comma, White space and dollar space is not
permitted in digits.
 25,0.000 , 7.1 e 4 , 1.5 E 2.5 (exponent must be
an integer),$255.
Single Character Constants
 A single character constant contains a single
character enclosed with a pair of single quotation
mark („ ‟).
 Example: „5‟, „x‟, „;‟ , „ ‟
 Note that character constant „5‟ is not same as
number 5.
 Character constant have a integer value known as
ASCII value
 Example :
 printf (“%d”, „a‟) would print the number 97.
 printf(“%c”, „97‟) would print the letter a.
String Constants
 A String Constant is a sequence of characters
enclosed in double quotation mark.
 Example: “Hello” , “1987”, “Well Done”, “X”
 Note : A single String constant does not have an
equivalent integer value, while a character constant
has an equivalent integer value.
Backslash Character Constant:
 Backslash character constant are used in output
function.
 Example: „n‟ new line,
„t‟ horizontal tab,
„‟‟ single quote etc.
Variables
 A variable is a data name that may be used to store a
data value.
 Unlike constants that remain unchanged during the
execution of the program, a variable may take
different value at different time.
Rules to declare the variables
 They must begin with letter or underscore(_)
 First character may be followed by letters or digits.
 Both lowercase and uppercase letters are distinct.
Example: Total and total are not same
 It should not be a keyword
 White space, Dollar sign are not allowed.
Example: John, delhi, First_tag, int_type ---- valid
Price$, char, group one, 123, (area) ------- Invalid
Declaration of variables
 Syntax : data_type v1,v2,v3….vn ;
where v1,v2..vn are different variable name.
 Example: int count;
int number, total;
double ratio;
float price;
char c;
where int, double, float and char are data type.
Assigning Values to variables
 Assignment operator (=) is used to assign value to a
variable.
 Example: price = 12.50;
ratio = 12.2345;
number=12;
c=„a‟;
Data Types
Primary Data Types
Integer Types
 Integers are whole numbers with a range of values
supported by a particular machine.
 There are signed integer and unsigned integer.
Signed integer uses one bit for sign and other bits for
magnitude of the number. Unsigned integers are
always positive. It does not contain any bit for sign
so that it occupies all the bit for the magnitude of the
number.
 By using equation -2^n to +(2^n)-1 we can find out
the range of the number. Where n is the number of
bits.
Size and Range of Integer Data
Floating Point Types
 Floating point numbers are stored in 32 bits with 6
digits of precision.
 Floating point numbers are defined in C by the
keyword float.
 When the accuracy provided by float is not sufficient
double data type is used. It uses 64 bits giving a
precision of 14 digits.
 When you want to extend more precision you can use
the long double data type. It uses 80 bits
Size and Range of Floating Point Data
Type Size(Bits) Range
float 32 3.4E-38 to 3.4E+38
double 64 1.7E-308 to 1.7E+308
long double 80 3.4E-4932 to 1.1E+4932
Void Types
 Void type has no values.
 Void type does not return any values.
 These are used to specify the return values from the
function when they don‟t have any value to return
Character Types
 Character types data in C are defined by keyword
char.
Type Size (bits) Range
char or signed char 8 -27 to 27 -1
unsigned char 8 0 to 28 -1
Typedef
 Using typedef keyword we can define our own user
defined data type.
 Syntax:
typedef type identifier;
 Example:
typedef int marks;
marks sub1,sub2;
Enumeration
 Declare using keyword enum
 Syntax:
enum identifier {value1, value2, value3,….,valueN};
 Example:
enum day {Monday, Tuesday,……..,Sunday};

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Fundamentals of c programming
Fundamentals of c programmingFundamentals of c programming
Fundamentals of c programming
 
Data types
Data typesData types
Data types
 
String functions in C
String functions in CString functions in C
String functions in C
 
C tokens
C tokensC tokens
C tokens
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
C string
C stringC string
C string
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
C keywords and identifiers
C keywords and identifiersC keywords and identifiers
C keywords and identifiers
 
Strings in C
Strings in CStrings in C
Strings in C
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Nested loops
Nested loopsNested loops
Nested loops
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 

Ähnlich wie Data Types and Variables In C Programming

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
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
Fundamentals of C Programming Language
Fundamentals of C Programming LanguageFundamentals of C Programming Language
Fundamentals of C Programming LanguageRamaBoya2
 
C language (more)
C language (more)C language (more)
C language (more)marar hina
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 
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
 
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
 
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
 
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
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxNithya K
 
Chapter 13.1.1
Chapter 13.1.1Chapter 13.1.1
Chapter 13.1.1patcha535
 

Ähnlich wie Data Types and Variables In C Programming (20)

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
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
Fundamentals of C Programming Language
Fundamentals of C Programming LanguageFundamentals of C Programming Language
Fundamentals of C Programming Language
 
C language (more)
C language (more)C language (more)
C language (more)
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
C presentation book
C presentation bookC presentation book
C presentation book
 
C Tutorial
C TutorialC Tutorial
C Tutorial
 
Mql4 manual
Mql4 manualMql4 manual
Mql4 manual
 
Mql4 manual
Mql4 manualMql4 manual
Mql4 manual
 
C tokens.pptx
C tokens.pptxC tokens.pptx
C tokens.pptx
 
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
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
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
 
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
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
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
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptx
 
Chapter 13.1.1
Chapter 13.1.1Chapter 13.1.1
Chapter 13.1.1
 
All C ppt.ppt
All C ppt.pptAll C ppt.ppt
All C ppt.ppt
 
C Token’s
C Token’sC Token’s
C Token’s
 

Mehr von Kamal Acharya

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computerKamal Acharya
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer SecurityKamal Acharya
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHPKamal Acharya
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in phpKamal Acharya
 
Text and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPText and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPKamal Acharya
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data WarehousingKamal Acharya
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data MiningKamal Acharya
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data MiningKamal Acharya
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data miningKamal Acharya
 
Introduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingIntroduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingKamal Acharya
 

Mehr von Kamal Acharya (20)

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer Security
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
Web forms in php
Web forms in phpWeb forms in php
Web forms in php
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHP
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
 
Text and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPText and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data Warehousing
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Search Engines
Search EnginesSearch Engines
Search Engines
 
Web Mining
Web MiningWeb Mining
Web Mining
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data Mining
 
Cluster Analysis
Cluster AnalysisCluster Analysis
Cluster Analysis
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data Mining
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data mining
 
Data Preprocessing
Data PreprocessingData Preprocessing
Data Preprocessing
 
Introduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingIntroduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data Warehousing
 

Kürzlich hochgeladen

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 

Kürzlich hochgeladen (20)

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 

Data Types and Variables In C Programming

  • 1. 1. INTRODUCTION 2. CHARACTER SET 3. C TOKENS 4. DATA TYPES Data Types and Variables
  • 2. Introduction  The Sequence of the Instruction written to perform specific task is called the Program.  This Instructions are formed using special symbols and words according to some rigid rule is known as syntax rules.  Every Instruction must be written according to the syntax rule of the languages.  Like any other languages C languages has its vocabulary and grammar. They are follow up for making the program.
  • 3. Character Set  Character Set is the set of the character.  This characters are used to form the word, numbers and expression.  The characters in the c are grouped into the following categories.  Letters : Uppercase A…Z, Lowercase a…z  Digits : All decimal digits 0 to 9  Special Character : ,(comma) .(period) ; (semicolon) :(colon), & (ampersand), # (number sign) etc.  White spaces : Blank Space, Horizontal Space, New Line.
  • 4. C Tokens  Smallest Individual units are known as C Tokens.  There are six types of the C Tokens.  Keywords  Identifiers  Constants  String  Special Symbols  Operators.
  • 5. Keywords  Every C word is classified as either keyword or identifier.  All keywords have fixed meanings and you can not change its meanings.  Keywords serve as a basic building blocks for program statement. ANSI C supports 32 keywords.  Ex: int, float, double, extern, static, auto, continue, if, goto short, long etc. are the keywords
  • 6. Identifiers  Identifiers refer to the names of variables, functions and arrays.  These are user defined names and consists of sequence of letters and digits.  Both uppercase and lowercase letters are permitted to make the identifier but generally lowercase letters are used to make the variable.
  • 7. Rules for Identifiers  First character must be alphabet  Must not contain white space  Only first 31 characters are significant  Can not use keyword as a identifier
  • 8. Constants  Constants referred as a fixed value that don't change during the execution of the program.  C Support Several types of constants:  Numeric Constants Integer constants Real Constants  Character Constants Single Character Constants String Constants
  • 9. Integer Constants  An integer constants refers as a sequence of digits.  There are three types of integer constants.  Decimal Integer  Octal Integer  Hexadecimal
  • 10. Decimal Integer  It consists of 0-9 digits, preceded by an optional – or + sign.  Valid example of decimal integer are : 123 , -321, 0 , 654321, +78  Embedded spaces, comma and non digit characters are not permitted between digits.  15 750, 20,000, $1000 are Illegal
  • 11. Octal Integer  An Octal Integers consists of digits 0-7 with a leading 0.  Example: 037, 0, 0435, 0551
  • 12. Hexadecimal Integer  A sequence of digits preceded by 0x or OX is considered as Hexadecimal Integer.  Hexadecimal Integer includes 0 to 9 digits and A to F letters.  Example: 0x9, 0x9F, OXBC etc are valid.
  • 13. Real Constants  Integer numbers are inadequate to represent quantities such as distance, heights, temperature, price and so on. These quantities are represented by a number containing fractional parts like 12.32. Such numbers are called real constants  These numbers having a whole number followed by a decimal digits.  Example: 0.85, -0.75, 85.45, +241.54
  • 14.  A real number may also be expressed in exponential (Scientific) notation.  General form :mantissa e exponent  The mantissa is either a real number or integer number.  Exponent is an integer number with + or – sign.  The letter e separating mantissa and exponent can be written either in lowercase or in uppercase letter.
  • 15.  Example : 215.65 may be written as 2.1565e2 in exponential notation. e2 means multiple by 10^2  75000 written as 7.5E4 or 7.5E+4  -0.00038 written as -3.8e-4  Comma, White space and dollar space is not permitted in digits.  25,0.000 , 7.1 e 4 , 1.5 E 2.5 (exponent must be an integer),$255.
  • 16. Single Character Constants  A single character constant contains a single character enclosed with a pair of single quotation mark („ ‟).  Example: „5‟, „x‟, „;‟ , „ ‟  Note that character constant „5‟ is not same as number 5.  Character constant have a integer value known as ASCII value
  • 17.  Example :  printf (“%d”, „a‟) would print the number 97.  printf(“%c”, „97‟) would print the letter a.
  • 18. String Constants  A String Constant is a sequence of characters enclosed in double quotation mark.  Example: “Hello” , “1987”, “Well Done”, “X”  Note : A single String constant does not have an equivalent integer value, while a character constant has an equivalent integer value.
  • 19. Backslash Character Constant:  Backslash character constant are used in output function.  Example: „n‟ new line, „t‟ horizontal tab, „‟‟ single quote etc.
  • 20. Variables  A variable is a data name that may be used to store a data value.  Unlike constants that remain unchanged during the execution of the program, a variable may take different value at different time.
  • 21. Rules to declare the variables  They must begin with letter or underscore(_)  First character may be followed by letters or digits.  Both lowercase and uppercase letters are distinct. Example: Total and total are not same  It should not be a keyword  White space, Dollar sign are not allowed. Example: John, delhi, First_tag, int_type ---- valid Price$, char, group one, 123, (area) ------- Invalid
  • 22. Declaration of variables  Syntax : data_type v1,v2,v3….vn ; where v1,v2..vn are different variable name.  Example: int count; int number, total; double ratio; float price; char c; where int, double, float and char are data type.
  • 23. Assigning Values to variables  Assignment operator (=) is used to assign value to a variable.  Example: price = 12.50; ratio = 12.2345; number=12; c=„a‟;
  • 26. Integer Types  Integers are whole numbers with a range of values supported by a particular machine.  There are signed integer and unsigned integer. Signed integer uses one bit for sign and other bits for magnitude of the number. Unsigned integers are always positive. It does not contain any bit for sign so that it occupies all the bit for the magnitude of the number.  By using equation -2^n to +(2^n)-1 we can find out the range of the number. Where n is the number of bits.
  • 27. Size and Range of Integer Data
  • 28. Floating Point Types  Floating point numbers are stored in 32 bits with 6 digits of precision.  Floating point numbers are defined in C by the keyword float.  When the accuracy provided by float is not sufficient double data type is used. It uses 64 bits giving a precision of 14 digits.  When you want to extend more precision you can use the long double data type. It uses 80 bits
  • 29. Size and Range of Floating Point Data Type Size(Bits) Range float 32 3.4E-38 to 3.4E+38 double 64 1.7E-308 to 1.7E+308 long double 80 3.4E-4932 to 1.1E+4932
  • 30. Void Types  Void type has no values.  Void type does not return any values.  These are used to specify the return values from the function when they don‟t have any value to return
  • 31. Character Types  Character types data in C are defined by keyword char. Type Size (bits) Range char or signed char 8 -27 to 27 -1 unsigned char 8 0 to 28 -1
  • 32. Typedef  Using typedef keyword we can define our own user defined data type.  Syntax: typedef type identifier;  Example: typedef int marks; marks sub1,sub2;
  • 33. Enumeration  Declare using keyword enum  Syntax: enum identifier {value1, value2, value3,….,valueN};  Example: enum day {Monday, Tuesday,……..,Sunday};