SlideShare une entreprise Scribd logo
1  sur  9
Constants and Variables in
C programming
Chitrank Dixit
Constants
Any unchanged value in a program during the program
execution is called constant. Following are the constants in C
language.
• Numeric Constants
• String or Character Constants.
Numeric Constants
• Integer Constant
– An integer constant is a signed or unsigned whole
number.
– Example: -23 +356 46
– C language supports an integer constant in octal
(base 8) , decimal (base 10) and hexadecimal
(base 16). The default number system followed in
C language is decimal (base 10).
– An octal number is preceded by zero (0) and a
hexadecimal number is preceded by 0x or 0X.
• Real or floating point constant:
– Any signed or unsigned number with fractional
part is called real or floating point constant. A real
constant can be written in decimal or exponential
form.
– Example
– Decimal Form 0.254 +342.0 -
3.15
– Exponential Form 0.218e6 0.42e-32 -
1.0e12
– (0.218e6 means --> 0.218 x 10^6 and so on for all)
String or Character Constants
• Any string of characters enclosed in apostrophes or
quotes is called string constant or character constant.
There are two types of string constants.
• Single Character String Constant
• String of Characters Constant
Single Character String Constant
• Any letter or character enclosed in single apostrophe
is called single character string constant.
– Example: 'y' '$' '+'
String of Characters Constant
• Any string of characters consisting of letters, digits
and symbols enclosed in double quotes is called
string of characters constant.
– Example:
– "Total value is“ , “12 vyas fala”, “value is = “
Variables
• A variable is an identifier or a name which is used to
refer a value and this value varies or changes during
the program execution. A variable is written with a
combination of letters , numbers and special
characters _(underscore) with the first letter being
an alphabet. Maximum of 31 letters can be used to
write a variable.
– Example: x , fact , c22 , total_value
Important rules while writing a
variable in C Programming
• Upper and Lower case alphabets are taken differently, so
the variables SUM and sum are referring to different
values.
• No special characters other than underscore ( _ ) are
permitted.
• Some C compilers will not accept more than 8 characters.
So it is a good practice writing a variable with few letters
which makes it also convenient to write and use
• All variables used in a C program are declared with
appropriate data types before the variable is assigned any
value.
• Reserved words cannot be used as variables.

Contenu connexe

Tendances

Tendances (20)

Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Character set in c
Character set in cCharacter set in c
Character set in c
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
History of c
History of cHistory of c
History of c
 
C language ppt
C language pptC language ppt
C language ppt
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
C Tokens
C TokensC Tokens
C Tokens
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
String functions in C
String functions in CString functions in C
String functions in C
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 

En vedette

The Literature Review Process
The Literature Review ProcessThe Literature Review Process
The Literature Review Processannielibrarian
 
Ethical issues in research
Ethical issues in researchEthical issues in research
Ethical issues in researchR.Harish Kumar
 
Educational research
Educational researchEducational research
Educational researchmeenuch
 
Characteristics and criteria of good research
Characteristics and criteria of good researchCharacteristics and criteria of good research
Characteristics and criteria of good researchA B
 
Literature review in research
Literature review in researchLiterature review in research
Literature review in researchNursing Path
 

En vedette (9)

Presentation on literature review
Presentation on literature reviewPresentation on literature review
Presentation on literature review
 
The Literature Review Process
The Literature Review ProcessThe Literature Review Process
The Literature Review Process
 
Concept, Construct and Variable
Concept, Construct and VariableConcept, Construct and Variable
Concept, Construct and Variable
 
The research instruments
The research instrumentsThe research instruments
The research instruments
 
Ethical issues in research
Ethical issues in researchEthical issues in research
Ethical issues in research
 
Educational research
Educational researchEducational research
Educational research
 
Literature Review
Literature ReviewLiterature Review
Literature Review
 
Characteristics and criteria of good research
Characteristics and criteria of good researchCharacteristics and criteria of good research
Characteristics and criteria of good research
 
Literature review in research
Literature review in researchLiterature review in research
Literature review in research
 

Similaire à Constants and variables in c programming

Similaire à Constants and variables in c programming (20)

INTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptxINTRODUCTION TO C++.pptx
INTRODUCTION TO C++.pptx
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
All C ppt.ppt
All C ppt.pptAll C ppt.ppt
All C ppt.ppt
 
COM1407: Variables and Data Types
COM1407: Variables and Data Types COM1407: Variables and Data Types
COM1407: Variables and Data Types
 
C presentation book
C presentation bookC presentation book
C presentation book
 
C
CC
C
 
Visual Basic Fundamentals
Visual Basic FundamentalsVisual Basic Fundamentals
Visual Basic Fundamentals
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
C PADHLO FRANDS.pdf
C PADHLO FRANDS.pdfC PADHLO FRANDS.pdf
C PADHLO FRANDS.pdf
 
C tokens.pptx
C tokens.pptxC tokens.pptx
C tokens.pptx
 
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
 
FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
 
C introduction
C introductionC introduction
C introduction
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
CHAPTER 2
CHAPTER 2CHAPTER 2
CHAPTER 2
 
Learn C# Programming - Variables & Constants
Learn C# Programming - Variables & ConstantsLearn C# Programming - Variables & Constants
Learn C# Programming - Variables & Constants
 
C Token’s
C Token’sC Token’s
C Token’s
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 

Dernier

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
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
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 

Dernier (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
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...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

Constants and variables in c programming

  • 1. Constants and Variables in C programming Chitrank Dixit
  • 2. Constants Any unchanged value in a program during the program execution is called constant. Following are the constants in C language. • Numeric Constants • String or Character Constants.
  • 3. Numeric Constants • Integer Constant – An integer constant is a signed or unsigned whole number. – Example: -23 +356 46 – C language supports an integer constant in octal (base 8) , decimal (base 10) and hexadecimal (base 16). The default number system followed in C language is decimal (base 10). – An octal number is preceded by zero (0) and a hexadecimal number is preceded by 0x or 0X.
  • 4. • Real or floating point constant: – Any signed or unsigned number with fractional part is called real or floating point constant. A real constant can be written in decimal or exponential form. – Example – Decimal Form 0.254 +342.0 - 3.15 – Exponential Form 0.218e6 0.42e-32 - 1.0e12 – (0.218e6 means --> 0.218 x 10^6 and so on for all)
  • 5. String or Character Constants • Any string of characters enclosed in apostrophes or quotes is called string constant or character constant. There are two types of string constants. • Single Character String Constant • String of Characters Constant
  • 6. Single Character String Constant • Any letter or character enclosed in single apostrophe is called single character string constant. – Example: 'y' '$' '+'
  • 7. String of Characters Constant • Any string of characters consisting of letters, digits and symbols enclosed in double quotes is called string of characters constant. – Example: – "Total value is“ , “12 vyas fala”, “value is = “
  • 8. Variables • A variable is an identifier or a name which is used to refer a value and this value varies or changes during the program execution. A variable is written with a combination of letters , numbers and special characters _(underscore) with the first letter being an alphabet. Maximum of 31 letters can be used to write a variable. – Example: x , fact , c22 , total_value
  • 9. Important rules while writing a variable in C Programming • Upper and Lower case alphabets are taken differently, so the variables SUM and sum are referring to different values. • No special characters other than underscore ( _ ) are permitted. • Some C compilers will not accept more than 8 characters. So it is a good practice writing a variable with few letters which makes it also convenient to write and use • All variables used in a C program are declared with appropriate data types before the variable is assigned any value. • Reserved words cannot be used as variables.