SlideShare a Scribd company logo
1
DATA TYPES
In the C Programming language, data types are defined as the
data storage format that a variable can store a data to
perform a specific operation and are used to define a
variable before to use in a program.
The type of a variable determines how much space it occupies in
storage and how the bit pattern stored is interpreted.
2
Name Description Size*
Example with syntax
Range*
char Character or small integer. 1 byte
char a=”abc”;
signed: -128 to 127
unsigned: 0 to 255
short int (short) Short Integer. 2 bytes
short int a;
signed: -32768 to 32767
unsigned: 0 to 65535
int Integer. 4 bytes
int s=10; signed: -2147483648 to
2147483647
unsigned: 0 to
4294967295
long int (long) Long integer. 4 bytes
long int s; signed: -2147483648 to
2147483647
unsigned: 0 to
4294967295
float Floating point number. 4 bytes
float s=10.256;
+/- 3.4e +/- 38 (~7
digits)
double
Double precision floating
point number.
8 bytes
double a=20.3568545
+/- 1.7e +/- 308 (~15
digits)
long double
Long double precision
floating point number.
8 bytes
Long double a;
+/- 1.7e +/- 308 (~15
digits)
5
INT DATA TYPE
Integers are whole numbers with a range of values, range of values are
machine dependent. Generally an integer occupies 2 bytes memory space
and its value range limited to -32768 to +32767.
Eg: int i=10;
6
CHAR DATA TYPE
Character type variable can hold a single character. As there
are singed and unsigned int (either short or long), in the same
way there are signed and unsigned chars; both occupy 1 byte
each, but having different ranges.
Unsigned characters have values between 0 and 255
signed characters have values from –128 to 127.
Eg: char a=”abc”;
7
FLOAT DATA TYPE
The float data type is used to store fractional numbers (real numbers) with 6
digits of precision. Floating point numbers are denoted by the keyword float.
When the accuracy of the floating point number is insufficient,one can use the
double to define the number. The double is same as float but with longer
precision and takes double space (8 bytes) than float. To extend the precision
further we can use long double which occupies 10 bytes of memory space.
Eg: float a=3.10;
8
VOID DATA TYPE
The void type has no values therefore we cannot declare it as
variable as we did in case of integer and float. The void data type is
usually used with function to specify its type. Like in our first C
program we declared "main ()" as void type because it does not
return any value.
Eg: void main();
9
DERIVED DATA TYPE
Array: An array in C language is a collection of similar data-type, means an
array can hold value of a particular data type for which it has been declared.
Arrays can be created from any of the basic C data-types .
Eg: int a[10];
String variable contains a collection of characters surrounded by
double quotes. e.g string greeting = "Hello";
Pointer: C Pointer is a special variable that can be used to store address of
another variable using & operator. * operator is used to assign
memory location to a
Eg: *int a;
10
Function
It is a block of code which only runs when it is called. And can pass data, known as
parameters, into a function.Functions are used to perform certain actions, and they are
important for reusing code: Define the code once, and use it many times.
C provides some pre-defined functions, such as main(), which is used to execute code. But you
can also create your own functions to perform certain actions.
To create (often referred to as declare) a function, specify the name of the function, followed
by parentheses ()
Syntax: return type function name(argument list);
Eg: void myFunction() {
// code to be executed
}
11
STRUCTURE DATA TYPE
CStructure isa collection of different data types which are grouped together and
each element in a C structure is called member.
Example:
struct student { int roll_no;
char name[20];
char city[20];
}
12
Union
It defines a type that contains a value that can be interpreted as different
types.
as it contains variables that uses the same space in the memory.
Its syntax is:
union union_name{
type1 name1;
type2 name2;
...
}
e.g union secretCode{
int i;
char str[4];
}
13
User defined Data Types:ENUMERATED DATA TYPE
(ENUM)
Enumerated data type is a user defined data type having finite set of
enumeration constants. The keyword 'enum' is used to create enumerated data
type. Enumeration data type consists of named integer constants as a list.
It start with 0 (zero) by default and value is incremented by 1 for the sequential
identifiers in the list.
Syntax:
Enum [data_type] {const1, const2… constn};
Eg: enum month {Jan,Feb, Mar };or /* Jan, Feb and Mar variables will be
assigned to 0, 1 and 2 respectively by default */
enum month {Jan= 1, Feb, Mar };/* Feb and Mar variables will be assigned to 2
and 3 respectively by default */
enum month {Jan = 20, Feb,Mar };/* Jan is assigned to 20. Feb and Mar
variables will be assigned to 21 and 22 respectively by default */ 14
TYPEDEF DATA TYPE
It is used to create new data type. But it is commonly used to change existing data
type with another name.
Syntax:
typedef [data_type] new_data_type;
here data_type is the basic type you want to substitute, while new_ data_type is the
name you want to give to it.
Eg:
typedef int integer;
integer roll_no;
15
THANK YOU
12
16

More Related Content

What's hot

Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
TejaswiB4
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
sai tarlekar
 
Function in C
Function in CFunction in C
Function in C
Dr. Abhineet Anand
 
Array in c
Array in cArray in c
Array in c
Ravi Gelani
 
C string
C stringC string
How to execute a C program
How to execute a C  program How to execute a C  program
How to execute a C program
Leela Koneru
 
Cursors
CursorsCursors
Data types in C
Data types in CData types in C
Data types in C
Ansh Kashyap
 
operators and control statements in c language
operators and control statements in c languageoperators and control statements in c language
operators and control statements in c language
shhanks
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
Dr-Dipali Meher
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
Venkata.Manish Reddy
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
Enums in c
Enums in cEnums in c
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
Qazi Shahzad Ali
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 

What's hot (20)

Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Function in C
Function in CFunction in C
Function in C
 
Array in c
Array in cArray in c
Array in c
 
C string
C stringC string
C string
 
How to execute a C program
How to execute a C  program How to execute a C  program
How to execute a C program
 
Cursors
CursorsCursors
Cursors
 
Data types in C
Data types in CData types in C
Data types in C
 
operators and control statements in c language
operators and control statements in c languageoperators and control statements in c language
operators and control statements in c language
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Strings in C
Strings in CStrings in C
Strings in C
 
Enums in c
Enums in cEnums in c
Enums in c
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 

Similar to Datatypes in 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++
Neeru Mittal
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
atifmugheesv
 
Data types
Data typesData types
Data types
Sachin Satwaskar
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
k v
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data typesManisha Keim
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGEPRASANYA K
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
Saad Sheikh
 
Data Handling
Data HandlingData Handling
Data Handling
Praveen M Jigajinni
 
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
SowmyaJyothi3
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
nikshaikh786
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
YRABHI
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
AqeelAbbas94
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6
REHAN IJAZ
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
nmahi96
 
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
Rai University
 
Data types
Data typesData types
Data types
Nokesh Prabhakar
 
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
Rai University
 
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
Rai University
 

Similar to Datatypes in c (20)

C++ data types
C++ data typesC++ data types
C++ data types
 
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
 
Data types
Data typesData types
Data types
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
 
Data Handling
Data HandlingData Handling
Data Handling
 
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
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
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
 
Data types
Data typesData types
Data types
 
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
 
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
 
Datatypes
DatatypesDatatypes
Datatypes
 

More from CGC Technical campus,Mohali

Gender Issues CS.pptx
Gender Issues CS.pptxGender Issues CS.pptx
Gender Issues CS.pptx
CGC Technical campus,Mohali
 
Intellectual Property Rights.pptx
Intellectual Property Rights.pptxIntellectual Property Rights.pptx
Intellectual Property Rights.pptx
CGC Technical campus,Mohali
 
Cyber Safety ppt.pptx
Cyber Safety ppt.pptxCyber Safety ppt.pptx
Cyber Safety ppt.pptx
CGC Technical campus,Mohali
 
Python Modules .pptx
Python Modules .pptxPython Modules .pptx
Python Modules .pptx
CGC Technical campus,Mohali
 
Dynamic allocation
Dynamic allocationDynamic allocation
Dynamic allocation
CGC Technical campus,Mohali
 
Arrays in c
Arrays in cArrays in c
Control statments in c
Control statments in cControl statments in c
Control statments in c
CGC Technical campus,Mohali
 
Operators in c by anupam
Operators in c by anupamOperators in c by anupam
Operators in c by anupam
CGC Technical campus,Mohali
 
Fundamentals of-computer
Fundamentals of-computerFundamentals of-computer
Fundamentals of-computer
CGC Technical campus,Mohali
 
Searching
Searching Searching
File handling-c
File handling-cFile handling-c
Structure in C language
Structure in C languageStructure in C language
Structure in C language
CGC Technical campus,Mohali
 
Function in c program
Function in c programFunction in c program
Function in c program
CGC Technical campus,Mohali
 
Function in c
Function in cFunction in c
string in C
string in Cstring in C
C arrays
C arraysC arrays
Data processing and Report writing in Research(Section E)
Data processing and Report writing in Research(Section E)Data processing and Report writing in Research(Section E)
Data processing and Report writing in Research(Section E)
CGC Technical campus,Mohali
 
data analysis and report wring in research (Section d)
data analysis and report wring  in research (Section d)data analysis and report wring  in research (Section d)
data analysis and report wring in research (Section d)
CGC Technical campus,Mohali
 
Section C(Analytical and descriptive surveys... )
Section C(Analytical and descriptive surveys... )Section C(Analytical and descriptive surveys... )
Section C(Analytical and descriptive surveys... )
CGC Technical campus,Mohali
 

More from CGC Technical campus,Mohali (20)

Gender Issues CS.pptx
Gender Issues CS.pptxGender Issues CS.pptx
Gender Issues CS.pptx
 
Intellectual Property Rights.pptx
Intellectual Property Rights.pptxIntellectual Property Rights.pptx
Intellectual Property Rights.pptx
 
Cyber Safety ppt.pptx
Cyber Safety ppt.pptxCyber Safety ppt.pptx
Cyber Safety ppt.pptx
 
Python Modules .pptx
Python Modules .pptxPython Modules .pptx
Python Modules .pptx
 
Dynamic allocation
Dynamic allocationDynamic allocation
Dynamic allocation
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Control statments in c
Control statments in cControl statments in c
Control statments in c
 
Operators in c by anupam
Operators in c by anupamOperators in c by anupam
Operators in c by anupam
 
Fundamentals of-computer
Fundamentals of-computerFundamentals of-computer
Fundamentals of-computer
 
Searching
Searching Searching
Searching
 
File handling-c
File handling-cFile handling-c
File handling-c
 
Structure in C language
Structure in C languageStructure in C language
Structure in C language
 
Intro
IntroIntro
Intro
 
Function in c program
Function in c programFunction in c program
Function in c program
 
Function in c
Function in cFunction in c
Function in c
 
string in C
string in Cstring in C
string in C
 
C arrays
C arraysC arrays
C arrays
 
Data processing and Report writing in Research(Section E)
Data processing and Report writing in Research(Section E)Data processing and Report writing in Research(Section E)
Data processing and Report writing in Research(Section E)
 
data analysis and report wring in research (Section d)
data analysis and report wring  in research (Section d)data analysis and report wring  in research (Section d)
data analysis and report wring in research (Section d)
 
Section C(Analytical and descriptive surveys... )
Section C(Analytical and descriptive surveys... )Section C(Analytical and descriptive surveys... )
Section C(Analytical and descriptive surveys... )
 

Recently uploaded

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 

Recently uploaded (20)

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 

Datatypes in c

  • 1. 1
  • 2. DATA TYPES In the C Programming language, data types are defined as the data storage format that a variable can store a data to perform a specific operation and are used to define a variable before to use in a program. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. 2
  • 3.
  • 4.
  • 5. Name Description Size* Example with syntax Range* char Character or small integer. 1 byte char a=”abc”; signed: -128 to 127 unsigned: 0 to 255 short int (short) Short Integer. 2 bytes short int a; signed: -32768 to 32767 unsigned: 0 to 65535 int Integer. 4 bytes int s=10; signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 long int (long) Long integer. 4 bytes long int s; signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 float Floating point number. 4 bytes float s=10.256; +/- 3.4e +/- 38 (~7 digits) double Double precision floating point number. 8 bytes double a=20.3568545 +/- 1.7e +/- 308 (~15 digits) long double Long double precision floating point number. 8 bytes Long double a; +/- 1.7e +/- 308 (~15 digits) 5
  • 6. INT DATA TYPE Integers are whole numbers with a range of values, range of values are machine dependent. Generally an integer occupies 2 bytes memory space and its value range limited to -32768 to +32767. Eg: int i=10; 6
  • 7. CHAR DATA TYPE Character type variable can hold a single character. As there are singed and unsigned int (either short or long), in the same way there are signed and unsigned chars; both occupy 1 byte each, but having different ranges. Unsigned characters have values between 0 and 255 signed characters have values from –128 to 127. Eg: char a=”abc”; 7
  • 8. FLOAT DATA TYPE The float data type is used to store fractional numbers (real numbers) with 6 digits of precision. Floating point numbers are denoted by the keyword float. When the accuracy of the floating point number is insufficient,one can use the double to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float. To extend the precision further we can use long double which occupies 10 bytes of memory space. Eg: float a=3.10; 8
  • 9. VOID DATA TYPE The void type has no values therefore we cannot declare it as variable as we did in case of integer and float. The void data type is usually used with function to specify its type. Like in our first C program we declared "main ()" as void type because it does not return any value. Eg: void main(); 9
  • 10. DERIVED DATA TYPE Array: An array in C language is a collection of similar data-type, means an array can hold value of a particular data type for which it has been declared. Arrays can be created from any of the basic C data-types . Eg: int a[10]; String variable contains a collection of characters surrounded by double quotes. e.g string greeting = "Hello"; Pointer: C Pointer is a special variable that can be used to store address of another variable using & operator. * operator is used to assign memory location to a Eg: *int a; 10
  • 11. Function It is a block of code which only runs when it is called. And can pass data, known as parameters, into a function.Functions are used to perform certain actions, and they are important for reusing code: Define the code once, and use it many times. C provides some pre-defined functions, such as main(), which is used to execute code. But you can also create your own functions to perform certain actions. To create (often referred to as declare) a function, specify the name of the function, followed by parentheses () Syntax: return type function name(argument list); Eg: void myFunction() { // code to be executed } 11
  • 12. STRUCTURE DATA TYPE CStructure isa collection of different data types which are grouped together and each element in a C structure is called member. Example: struct student { int roll_no; char name[20]; char city[20]; } 12
  • 13. Union It defines a type that contains a value that can be interpreted as different types. as it contains variables that uses the same space in the memory. Its syntax is: union union_name{ type1 name1; type2 name2; ... } e.g union secretCode{ int i; char str[4]; } 13
  • 14. User defined Data Types:ENUMERATED DATA TYPE (ENUM) Enumerated data type is a user defined data type having finite set of enumeration constants. The keyword 'enum' is used to create enumerated data type. Enumeration data type consists of named integer constants as a list. It start with 0 (zero) by default and value is incremented by 1 for the sequential identifiers in the list. Syntax: Enum [data_type] {const1, const2… constn}; Eg: enum month {Jan,Feb, Mar };or /* Jan, Feb and Mar variables will be assigned to 0, 1 and 2 respectively by default */ enum month {Jan= 1, Feb, Mar };/* Feb and Mar variables will be assigned to 2 and 3 respectively by default */ enum month {Jan = 20, Feb,Mar };/* Jan is assigned to 20. Feb and Mar variables will be assigned to 21 and 22 respectively by default */ 14
  • 15. TYPEDEF DATA TYPE It is used to create new data type. But it is commonly used to change existing data type with another name. Syntax: typedef [data_type] new_data_type; here data_type is the basic type you want to substitute, while new_ data_type is the name you want to give to it. Eg: typedef int integer; integer roll_no; 15