SlideShare une entreprise Scribd logo
1  sur  8
Constants, Variables and Data Types
Topics
 Token, Keyword, Identifier
 Constant, Variable
 Data types
Token and Keyword
 Token- In a C program the smallest individual units
are known as C tokens. C has six types of tokens.
1. Keyword- float, int, while
2. Identifier- main, amount
3. Constant- 10.5, 10
4. String- “ABC”, “Khulna”
5. Special symbol- [ ], { }
6. Operator- +,-,*
 Keyword- Keywords are the reserve words which
have fixed meanings and that cannot be changed.
Ex- float, double, while, char, do, if, else
Identifier, Constant
 Identifier- Identifiers refer to the names of variables,
functions and arrays.
 Constant- Constants in C refer to fixed values do
not change during the execution of a program. Ex-
123, -0.75, ‘X’, “CSE”
 Process of declaring constant:
1. #define: #define const_name value
Ex: #define MAX 100
2. const: const data_type const_name = value;
Ex: const int MAX=100;
Variable
 Variable- A variable is a data name that may be
used to store data value. A variable may take
different values at different times during execution.
 Rules of variable name:
1. It must begin with a letter. Some systems permit
underscore as the first character.
2. ANSI standard recognizes a length of 31
characters. But it should normally in between 8 char.
3. Uppercase and lowercase are different.
4. Variable name should not be a keyword.
5. White space is not allowed.
Data Types
 Primary data types- character, Integer, Float,
Double
 User-defined data types- Structure, Union, Class,
Enumeration
 Derived data types- Array, Function, Pointer,
Reference
Modifier or Qualifier
 Modifier- The keyword like short, long, unsigned,
signed can change the data storage capacity of the
variable. So they are called modifier or qualifier.
 Type Size (bits) Range
char 8 -128 to 127
int or short int 16 -32768 to 32767
unsigned int 16 0 to 65535
short int 8 -128 to 127
long int 32 -2147483648 to 2147483648
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 3.4E+4932
Variable Declaration
 Declaration does two things:
1. It tells the compiler what the variable name
is.
2. It specifies what type of data the variable
will hold.
 The declaration of variables must be done
before they are used in the program.
 Rule: Data_type Var_name;
 Ex: int x, y;
float area;
Assigning values to Variables
 Rule: var_name = constant;
Ex: balance = 1277.50;
ch = ‘Y’;
 C permits multiple assignments in one line.
Ex: length=10; height=5;
 It is also possible to assign a value to a variable at
the time of variable declaration.
Ex: int x = 100;
 C permits the initialization of more than one
variables in one statement using multiple
assignment operators.
Ex: x = y = z = 100;

Contenu connexe

Tendances

Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Typesk v
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data typesManisha Keim
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data TypesTareq Hasan
 
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
 
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
 
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
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++Ameer Khan
 
Data types in C language
Data types in C languageData types in C language
Data types in C languagekashyap399
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++ Hridoy Bepari
 
Structures in c language
Structures in c languageStructures in c language
Structures in c languagetanmaymodi4
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++NIDA HUSSAIN
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures topu93
 

Tendances (20)

Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Data types
Data typesData types
Data types
 
C++ data types
C++ data typesC++ data types
C++ data types
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
Data types
Data typesData types
Data types
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
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
 
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
 
Data types in C
Data types in CData types in C
Data types in C
 
Data types in C
Data types in CData types in C
Data types in 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
 
Data types
Data typesData types
Data types
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Ch 2.
Ch 2.Ch 2.
Ch 2.
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
 
Numerical data.
Numerical data.Numerical data.
Numerical data.
 

En vedette

Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4sotlsoc
 
Chapter 3.1
Chapter 3.1Chapter 3.1
Chapter 3.1sotlsoc
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure Eman magdy
 
Webpage Visual Design and Online Prototype
Webpage Visual Design and Online PrototypeWebpage Visual Design and Online Prototype
Webpage Visual Design and Online Prototypeamoore155
 
Logic Formulation 2
Logic Formulation 2Logic Formulation 2
Logic Formulation 2deathful
 
Calculus II - 16
Calculus II - 16Calculus II - 16
Calculus II - 16David Mao
 
Calculus II - 15
Calculus II - 15Calculus II - 15
Calculus II - 15David Mao
 
Problem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - ListsProblem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - ListsYi-Lung Tsai
 
Problem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - GraphsProblem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - GraphsYi-Lung Tsai
 
Komunikasyon
KomunikasyonKomunikasyon
Komunikasyondeathful
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceTransweb Global Inc
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++Ngeam Soly
 
Earthing Concepts
Earthing ConceptsEarthing Concepts
Earthing Conceptsmvrkprasad
 
Electrical grounding and earthing
Electrical grounding and earthingElectrical grounding and earthing
Electrical grounding and earthingNitesh Dash
 

En vedette (20)

Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4
 
Chapter 3.1
Chapter 3.1Chapter 3.1
Chapter 3.1
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
 
Webpage Visual Design and Online Prototype
Webpage Visual Design and Online PrototypeWebpage Visual Design and Online Prototype
Webpage Visual Design and Online Prototype
 
Logic Formulation 2
Logic Formulation 2Logic Formulation 2
Logic Formulation 2
 
2. electric field calculation
2. electric field calculation2. electric field calculation
2. electric field calculation
 
Calculus II - 16
Calculus II - 16Calculus II - 16
Calculus II - 16
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
 
Calculus II - 15
Calculus II - 15Calculus II - 15
Calculus II - 15
 
Problem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - ListsProblem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - Lists
 
Problem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - GraphsProblem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - Graphs
 
Komunikasyon
KomunikasyonKomunikasyon
Komunikasyon
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
 
ppt of VCLA
ppt of VCLAppt of VCLA
ppt of VCLA
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++
 
Curves and surfaces
Curves and surfacesCurves and surfaces
Curves and surfaces
 
Earthing Concepts
Earthing ConceptsEarthing Concepts
Earthing Concepts
 
Electrical grounding and earthing
Electrical grounding and earthingElectrical grounding and earthing
Electrical grounding and earthing
 

Similaire à Chap 2(const var-datatype)

variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsatifmugheesv
 
Visual Basic Fundamentals
Visual Basic FundamentalsVisual Basic Fundamentals
Visual Basic FundamentalsDivyaR219113
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfYRABHI
 
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
 
java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming NeedsRaja Sekhar
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.pptAqeelAbbas94
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2rohassanie
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingAbha Damani
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniquesvalarpink
 
Chapter 2 basic element of programming
Chapter 2 basic element of programming Chapter 2 basic element of programming
Chapter 2 basic element of programming Zul Aiman
 
Introduction to c
Introduction to cIntroduction to c
Introduction to cAjeet Kumar
 
Basic Structure Of C++
Basic Structure Of C++Basic Structure Of C++
Basic Structure Of C++DevangiParekh1
 

Similaire à Chap 2(const var-datatype) (20)

PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
Data Handling
Data HandlingData Handling
Data Handling
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
 
Visual Basic Fundamentals
Visual Basic FundamentalsVisual Basic Fundamentals
Visual Basic Fundamentals
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
 
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
 
java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming Needs
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
Java chapter 2
Java chapter 2Java chapter 2
Java chapter 2
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Python
PythonPython
Python
 
Chapter 2 basic element of programming
Chapter 2 basic element of programming Chapter 2 basic element of programming
Chapter 2 basic element of programming
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Basic Structure Of C++
Basic Structure Of C++Basic Structure Of C++
Basic Structure Of C++
 

Plus de Bangabandhu Sheikh Mujibur Rahman Science and Technology University

Plus de Bangabandhu Sheikh Mujibur Rahman Science and Technology University (20)

Antenna (2)
Antenna (2)Antenna (2)
Antenna (2)
 
Voltage suppler..
Voltage suppler..Voltage suppler..
Voltage suppler..
 
Number system
Number systemNumber system
Number system
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Chap 13(dynamic memory allocation)
Chap 13(dynamic memory allocation)Chap 13(dynamic memory allocation)
Chap 13(dynamic memory allocation)
 
Chap 12(files)
Chap 12(files)Chap 12(files)
Chap 12(files)
 
Chap 11(pointers)
Chap 11(pointers)Chap 11(pointers)
Chap 11(pointers)
 
Chap 10(structure and unions)
Chap 10(structure and unions)Chap 10(structure and unions)
Chap 10(structure and unions)
 
Chap 9(functions)
Chap 9(functions)Chap 9(functions)
Chap 9(functions)
 
Chap 8(strings)
Chap 8(strings)Chap 8(strings)
Chap 8(strings)
 
Chap 7(array)
Chap 7(array)Chap 7(array)
Chap 7(array)
 
Chap 6(decision making-looping)
Chap 6(decision making-looping)Chap 6(decision making-looping)
Chap 6(decision making-looping)
 
Chap 5(decision making-branching)
Chap 5(decision making-branching)Chap 5(decision making-branching)
Chap 5(decision making-branching)
 
Chap 3(operator expression)
Chap 3(operator expression)Chap 3(operator expression)
Chap 3(operator expression)
 
Computer hardware ppt1
Computer hardware ppt1Computer hardware ppt1
Computer hardware ppt1
 
# Operating system
# Operating system# Operating system
# Operating system
 
Magnetism 3
Magnetism 3Magnetism 3
Magnetism 3
 
Magnetism 2
Magnetism 2Magnetism 2
Magnetism 2
 
2. sinusoidal waves
2. sinusoidal waves2. sinusoidal waves
2. sinusoidal waves
 
Magnetism 1
Magnetism 1Magnetism 1
Magnetism 1
 

Dernier

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 

Dernier (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Chap 2(const var-datatype)

  • 1. Constants, Variables and Data Types Topics  Token, Keyword, Identifier  Constant, Variable  Data types
  • 2. Token and Keyword  Token- In a C program the smallest individual units are known as C tokens. C has six types of tokens. 1. Keyword- float, int, while 2. Identifier- main, amount 3. Constant- 10.5, 10 4. String- “ABC”, “Khulna” 5. Special symbol- [ ], { } 6. Operator- +,-,*  Keyword- Keywords are the reserve words which have fixed meanings and that cannot be changed. Ex- float, double, while, char, do, if, else
  • 3. Identifier, Constant  Identifier- Identifiers refer to the names of variables, functions and arrays.  Constant- Constants in C refer to fixed values do not change during the execution of a program. Ex- 123, -0.75, ‘X’, “CSE”  Process of declaring constant: 1. #define: #define const_name value Ex: #define MAX 100 2. const: const data_type const_name = value; Ex: const int MAX=100;
  • 4. Variable  Variable- A variable is a data name that may be used to store data value. A variable may take different values at different times during execution.  Rules of variable name: 1. It must begin with a letter. Some systems permit underscore as the first character. 2. ANSI standard recognizes a length of 31 characters. But it should normally in between 8 char. 3. Uppercase and lowercase are different. 4. Variable name should not be a keyword. 5. White space is not allowed.
  • 5. Data Types  Primary data types- character, Integer, Float, Double  User-defined data types- Structure, Union, Class, Enumeration  Derived data types- Array, Function, Pointer, Reference
  • 6. Modifier or Qualifier  Modifier- The keyword like short, long, unsigned, signed can change the data storage capacity of the variable. So they are called modifier or qualifier.  Type Size (bits) Range char 8 -128 to 127 int or short int 16 -32768 to 32767 unsigned int 16 0 to 65535 short int 8 -128 to 127 long int 32 -2147483648 to 2147483648 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 3.4E+4932
  • 7. Variable Declaration  Declaration does two things: 1. It tells the compiler what the variable name is. 2. It specifies what type of data the variable will hold.  The declaration of variables must be done before they are used in the program.  Rule: Data_type Var_name;  Ex: int x, y; float area;
  • 8. Assigning values to Variables  Rule: var_name = constant; Ex: balance = 1277.50; ch = ‘Y’;  C permits multiple assignments in one line. Ex: length=10; height=5;  It is also possible to assign a value to a variable at the time of variable declaration. Ex: int x = 100;  C permits the initialization of more than one variables in one statement using multiple assignment operators. Ex: x = y = z = 100;