SlideShare a Scribd company logo
9
Most read
11
Most read
12
Most read
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

PPTX
ARRAY
PPTX
PDF
Cours c++
PPTX
C++ theory
PDF
Data structure using c++
PPT
Linked List
PPTX
Structure in c language
PPTX
Stack and Queue
ARRAY
Cours c++
C++ theory
Data structure using c++
Linked List
Structure in c language
Stack and Queue

What's hot (19)

PPT
Pointers
PDF
Python 3.x quick syntax guide
PPTX
Data structures
DOCX
C++ file
PPTX
sorting and its types
PPTX
Abstract Data Types
PPTX
PPSX
C++ Programming Language
PPSX
Data Structure (Stack)
PPT
C statements.ppt presentation in c language
PPTX
Functions in c
PPTX
Queue Implementation Using Array & Linked List
PPTX
C++ Object Oriented Programming
PPT
Relational algebra
PPTX
File handling in c++
PPTX
Classes and objects1
PPT
C++ Arrays
PPTX
Database constraints
PPT
UML Prezentation class diagram
Pointers
Python 3.x quick syntax guide
Data structures
C++ file
sorting and its types
Abstract Data Types
C++ Programming Language
Data Structure (Stack)
C statements.ppt presentation in c language
Functions in c
Queue Implementation Using Array & Linked List
C++ Object Oriented Programming
Relational algebra
File handling in c++
Classes and objects1
C++ Arrays
Database constraints
UML Prezentation class diagram
Ad

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

PPTX
Data Types in C language
PPTX
Data types
PPTX
Data types in C language
PPTX
Data-Types-in-C-Programming.Programming.pptxProgramming.pptxpptx
PPTX
C Programming : data types and types of variable.pptx
PPTX
data types in C programming
PDF
cassignmentii-170424105623.pdf
PPT
Structured Programming with C - Data Types.ppt
PPTX
Datatypes
PPTX
Lecture 2 introduction to Programming languages C.pptx
PPT
C language Unit 2 Slides, UPTU C language
PDF
Data types in c++
PPTX
Programming Fundamentals lecture 6
PPTX
Data types in C
PPTX
datatypes-200723165518 (1).pptx
PDF
Data structure & Algorithms - Programming in C
PPTX
What is Data Types and Functions?
PPTX
PPTX
COM1407: Variables and Data Types
PPTX
Memory management of datatypes
Data Types in C language
Data types
Data types in C language
Data-Types-in-C-Programming.Programming.pptxProgramming.pptxpptx
C Programming : data types and types of variable.pptx
data types in C programming
cassignmentii-170424105623.pdf
Structured Programming with C - Data Types.ppt
Datatypes
Lecture 2 introduction to Programming languages C.pptx
C language Unit 2 Slides, UPTU C language
Data types in c++
Programming Fundamentals lecture 6
Data types in C
datatypes-200723165518 (1).pptx
Data structure & Algorithms - Programming in C
What is Data Types and Functions?
COM1407: Variables and Data Types
Memory management of datatypes
Ad

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
A Presentation on Artificial Intelligence
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Modernizing your data center with Dell and AMD
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
A Presentation on Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Building Integrated photovoltaic BIPV_UPV.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Understanding_Digital_Forensics_Presentation.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Dropbox Q2 2025 Financial Results & Investor Presentation
Modernizing your data center with Dell and AMD
Encapsulation_ Review paper, used for researhc scholars
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf

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; }