SlideShare a Scribd company logo
1 of 16
Built in data types
in C language
Contents
 Introduction
 Classification of Data types
 Primitive data types
 Integer data type
 Floating point data type
 Character data type
 Void data type
Data Types in C Language
Introduction:
 In C programming, data types are declarations for variables. This
determines the type and size of data associated with variables.
 data type is used for allocating memory for storing value in a program
by specifying the required numbers of bytes and memory type.
For ex: int x=5; x
5
Value
2 Bytes
int
Classification of Data Types
Modifiers:
• Modifiers are prefixed with basic data types to modify (either
increase or decrease) the amount of storage space allocated to a
variable.
• There are two types of type modifiers:
• Size modifiers - short, long (can be used with int and double)
• Sign modifiers - signed, unsigned(can be used with int and char data
type)
Primitive(or Basic or Built in) Data
types
Integer Data Types:
The keyword int is used to declare integer data type.
For Ex: int var1; Data type Format specifier Size (in bytes)
short int %d 2
signed short int %d 2
unsigned short int %u 2
int %d
2 or 4(complier
dependent)
signed int %d 4
unsigned int %u 4
long int %ld 4
signed long int %ld 4
unsigned long int %lu 4
long long int %lld 8
unsigned long long
%llu 8
Formula for Range:
a) Let the size of signed int is
n bits then range is-
-2n-1 to +(2n-1 -1)
b) For unsigned int:
0 to 2n-1
Example: #include<stdio.h>
int main ()
{
short a = 10; //short data type
short int a1 = 20;
int a2 = 1000; //int data type
long a3 = 100000000; //long data type
long int a4 = 200000000;
long long a5 = 500000000000;//long long data type
long long int a6 = 900000000000;
printf("%dn",a);
printf("%dn",a1);
printf("%dn",a2);
printf("%ldn",a3);
printf("%ldn",a4);
printf("%lldn",a5);
printf("%lldn",a6); return 0; }
Output:-
10
20
1000
100000000
200000000
500000000000
900000000000
Float Data type:
• All numeric data type items with fractional part belong to float type.
• The keyword float is used to declare variables of float type.
Ex: float var1;
• By default, every floating-point number is treated as a double data
type. Float and long double data type are also used for floating-point.
• Generally, the size of the float data type is 4 bytes and the double
data type is 8 bytes.
• In floating point numbers the precision describes the number of
significant decimal places that a floating value carries.
Continue…….
Data types Format
Specifier
Size(In
Bytes)
Digits of
Precision
float %f 4 6
double %lf 8 15
long double %Lf 10 19
Character data type
• In C language, to store character data types keyword char is used.
• For character type variables and single-character constants, 1 byte (8
bits) of memory space is allocated.
• It is classified under the integral data type as the storage occurs in
the form of ASCII values which are used to represent every character.
For Ex: ‘a’ has the decimal value 97.
• Example of char data types:- ‘m’, ‘A’, ‘5’, ‘@’, ‘?’ e.t.c.
Note: All are inside the single quotation.
Continue….
Data Type Format
Specifier
Size(in Byte) Range
unsigned char %c 1 0 to 255
char %c 1 -128 to 127
signed char %c 1 -128 to 127
Continue…..
• “a” is a char data type?
Ans: No
• ‘abc’ is a char data type?
Ans: No
‘a ’ is a char data type?
Ans: Yes
Void Data Type:
• As the name indicates this type has no values.
• Most of the times it is used to indicate that a function does not
return any value.
• All other primitive data types short, int, long int, float, double and
long double can be used for both calculation (like storing values to a
variable) and returning from a function but void can only be used for
returning from a function.
• Void can’t be used for storing and calculation in a program.
Examples:
1. When used as a function returntype:
the void keyword specifies that the function does not returna value.
void show()
{
printf("This function has no return type");
}
2. When used for a function's parameterlist:
void specifiesthat the function takes no parameters.
int sum(void)
{
int a,b;
printf("Enter Two number>> ");
scanf("%d%d",&a,&b);
return a+b;
}
Thank
You

More Related Content

Similar to Unit 1 Built in Data types in C language.ppt

A Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and ExpressionsA Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and ExpressionsInan Mashrur
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c programAlamgir Hossain
 
datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxNaniBhai3
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structsSaad Sheikh
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++Neeru Mittal
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsatifmugheesv
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++Ankur Pandey
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointersSamiksha Pun
 
C/C++ language Presentation
C/C++ language PresentationC/C++ language Presentation
C/C++ language PresentationS.Saeed H
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)guest58c84c
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)jahanullah
 
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
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxLESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxjoachimbenedicttulau
 

Similar to Unit 1 Built in Data types in C language.ppt (20)

A Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and ExpressionsA Closer Look at Data Types, Variables and Expressions
A Closer Look at Data Types, Variables and Expressions
 
2. introduction of a c program
2. introduction of a c program2. introduction of a c program
2. introduction of a c program
 
datatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptxdatatypes-200723165518 (1).pptx
datatypes-200723165518 (1).pptx
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
C
CC
C
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Theory1&amp;2
 
Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++Keywords, identifiers ,datatypes in C++
Keywords, identifiers ,datatypes in C++
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
 
C/C++ language Presentation
C/C++ language PresentationC/C++ language Presentation
C/C++ language Presentation
 
C presentation book
C presentation bookC presentation book
C presentation book
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
 
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
 
LESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptxLESSON1-C_programming (1).GRADE 8 LESSONpptx
LESSON1-C_programming (1).GRADE 8 LESSONpptx
 

Recently uploaded

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Unit 1 Built in Data types in C language.ppt

  • 1. Built in data types in C language
  • 2. Contents  Introduction  Classification of Data types  Primitive data types  Integer data type  Floating point data type  Character data type  Void data type
  • 3. Data Types in C Language Introduction:  In C programming, data types are declarations for variables. This determines the type and size of data associated with variables.  data type is used for allocating memory for storing value in a program by specifying the required numbers of bytes and memory type. For ex: int x=5; x 5 Value 2 Bytes int
  • 5. Modifiers: • Modifiers are prefixed with basic data types to modify (either increase or decrease) the amount of storage space allocated to a variable. • There are two types of type modifiers: • Size modifiers - short, long (can be used with int and double) • Sign modifiers - signed, unsigned(can be used with int and char data type)
  • 6. Primitive(or Basic or Built in) Data types
  • 7. Integer Data Types: The keyword int is used to declare integer data type. For Ex: int var1; Data type Format specifier Size (in bytes) short int %d 2 signed short int %d 2 unsigned short int %u 2 int %d 2 or 4(complier dependent) signed int %d 4 unsigned int %u 4 long int %ld 4 signed long int %ld 4 unsigned long int %lu 4 long long int %lld 8 unsigned long long %llu 8 Formula for Range: a) Let the size of signed int is n bits then range is- -2n-1 to +(2n-1 -1) b) For unsigned int: 0 to 2n-1
  • 8. Example: #include<stdio.h> int main () { short a = 10; //short data type short int a1 = 20; int a2 = 1000; //int data type long a3 = 100000000; //long data type long int a4 = 200000000; long long a5 = 500000000000;//long long data type long long int a6 = 900000000000; printf("%dn",a); printf("%dn",a1); printf("%dn",a2); printf("%ldn",a3); printf("%ldn",a4); printf("%lldn",a5); printf("%lldn",a6); return 0; } Output:- 10 20 1000 100000000 200000000 500000000000 900000000000
  • 9. Float Data type: • All numeric data type items with fractional part belong to float type. • The keyword float is used to declare variables of float type. Ex: float var1; • By default, every floating-point number is treated as a double data type. Float and long double data type are also used for floating-point. • Generally, the size of the float data type is 4 bytes and the double data type is 8 bytes. • In floating point numbers the precision describes the number of significant decimal places that a floating value carries.
  • 10. Continue……. Data types Format Specifier Size(In Bytes) Digits of Precision float %f 4 6 double %lf 8 15 long double %Lf 10 19
  • 11. Character data type • In C language, to store character data types keyword char is used. • For character type variables and single-character constants, 1 byte (8 bits) of memory space is allocated. • It is classified under the integral data type as the storage occurs in the form of ASCII values which are used to represent every character. For Ex: ‘a’ has the decimal value 97. • Example of char data types:- ‘m’, ‘A’, ‘5’, ‘@’, ‘?’ e.t.c. Note: All are inside the single quotation.
  • 12. Continue…. Data Type Format Specifier Size(in Byte) Range unsigned char %c 1 0 to 255 char %c 1 -128 to 127 signed char %c 1 -128 to 127
  • 13. Continue….. • “a” is a char data type? Ans: No • ‘abc’ is a char data type? Ans: No ‘a ’ is a char data type? Ans: Yes
  • 14. Void Data Type: • As the name indicates this type has no values. • Most of the times it is used to indicate that a function does not return any value. • All other primitive data types short, int, long int, float, double and long double can be used for both calculation (like storing values to a variable) and returning from a function but void can only be used for returning from a function. • Void can’t be used for storing and calculation in a program.
  • 15. Examples: 1. When used as a function returntype: the void keyword specifies that the function does not returna value. void show() { printf("This function has no return type"); } 2. When used for a function's parameterlist: void specifiesthat the function takes no parameters. int sum(void) { int a,b; printf("Enter Two number>> "); scanf("%d%d",&a,&b); return a+b; }