SlideShare uma empresa Scribd logo
1 de 18
DATA TYPES
•Data types are used to define a variable before it
can be used in a program.
•C data types are defined as the data storage format
that a variable can store a data to perform a specific
operation.
Data Types
 Data Types is further divided into 3 parts.
1. Primitive
2. Derived
3. User Defined
Ranges of Data Types
Integer Data Type
 Integer data type allows a variable to store
numeric values.
 “int” keyword is used to refer integer data type.
 The storage size of int data type is 2 bytes.
 int (2 byte) can store values from -32,768 to
+32,767
 If you want to use the integer value that
crosses the above limit, you can go for “long
int” for which the limits are very high.
General Syntax to declare int
void main()
{
int a,b; // Here we have declared 2 integers
}
Each ‘a’ and ‘b’ will take 2 bytes each so 4 bytes
will be stored in the memory
Character
 Character data type allows a variable to store
only one character.
 Storage size of character data type is 1. We
can store only one character using character
data type.
 “char” keyword is used to refer character data
type. Character takes only 1 byte and has a
range from -128 to 127.
 For example, ‘A’ can be stored using char
datatype. You can’t store more than one
character using char data type.
General Syntax to declare
Character
void main()
{
char a,b; // Here we have declared 2
characters
}
Each ‘a’ and ‘b’ will take 1 byte each so 2 bytes
will be stored in the memory
Float Data Type
 Float data type allows a variable to store
decimal values.
 Storage size of float data type is 4.
 We can use up-to 6 digits after decimal using
float data type.
 For example, 10.456789 can be stored in a
variable using float data type.
 Range of Float is -3.4e38 to +3.4e38
General Syntax to declare Float
void main()
{
float a,b; // Here we have declared 2 float
variables
}
Each ‘a’ and ‘b’ will take 4 bytes each so 8 bytes
will be stored in the memory
Double Data type
 Double data type is also same as float data
type which allows up-to 10 digits after decimal.
 The range for double datatype is from 1E–37
to 1E+37.
 It takes double the memory space as float. It
takes 8 bytes.
General Syntax to declare Float
void main()
{
double a,b; // Here we have declared 2 double
variables
}
Each ‘a’ and ‘b’ will take 8 bytes each so 16
bytes will be stored in the memory
Void Data Type
 Void is an empty data type that has no value.
 This can be used in functions and pointers.
 General Syntax
void main()
{
}
Enum
 An enum is a keyword, it is an user defined
data type. All properties of integer are applied
on Enumeration data type so size of the
enumerator data type is 2 byte. It work like the
Integer.
 It is used for creating an user defined data
type of integer. Using enum we can create
sequence of integer constant value.
Syntax of enum
 enum tagname {value1, value2, value3,....};
 In above syntax enum is a keyword. It is a
user defined data type.
 In above syntax tagname is our own variable.
tagname is any variable name.
 value1, value2, value3,.... are create set of
enum values.
It is start with 0 (zero) by default and value is incremented
by 1 for the sequential identifiers in the list. If constant one
value is not initialized then by default sequence will be start
from zero and next to generated value should be previous
constant value one.
Program of Enum
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
enum ABC {x,y,z};
clrscr();
a=x+y+z;
printf("Sum: %d",a);
getch();
}
Enum
#include <stdio.h>
#include<conio.h>
void main()
{
int today;
enum week{ sun,mon,tue,wed,thu,fri,sat};
clrscr();
today = wed;
printf("Day %d",today+1);
getch();
}

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Numeric Data Types & Strings
Numeric Data Types & StringsNumeric Data Types & Strings
Numeric Data Types & Strings
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
html-table
html-tablehtml-table
html-table
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Computer data type and Terminologies
Computer data type and Terminologies Computer data type and Terminologies
Computer data type and Terminologies
 
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++
 
Branching statements
Branching statementsBranching statements
Branching statements
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
 
Structure in c
Structure in cStructure in c
Structure in c
 
arrays in c
arrays in carrays in c
arrays in c
 
Spreadsheet-Software
Spreadsheet-SoftwareSpreadsheet-Software
Spreadsheet-Software
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
C++ data types
C++ data typesC++ data types
C++ data types
 
Built in function
Built in functionBuilt in function
Built in function
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 

Semelhante a Data types

CIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and VariablesCIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and VariablesHamad Odhabi
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programmingnmahi96
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsatifmugheesv
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGEPRASANYA K
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotesSowri Rajan
 
Learning VB.NET Programming Concepts
Learning VB.NET Programming ConceptsLearning VB.NET Programming Concepts
Learning VB.NET Programming Conceptsguest25d6e3
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6REHAN IJAZ
 
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfCOMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfrajkumar2792005
 
Data Type is a basic classification which identifies.docx
Data Type is a basic classification which identifies.docxData Type is a basic classification which identifies.docx
Data Type is a basic classification which identifies.docxtheodorelove43763
 

Semelhante a Data types (20)

Data types in C
Data types in CData types in C
Data types in C
 
Data types
Data typesData types
Data types
 
Variable
VariableVariable
Variable
 
Datatypes in c
Datatypes in cDatatypes in c
Datatypes in c
 
CIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and VariablesCIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and Variables
 
Strings-Computer programming
Strings-Computer programmingStrings-Computer programming
Strings-Computer programming
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
 
Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
 
5. variables & data types
5. variables & data types5. variables & data types
5. variables & data types
 
Learning VB.NET Programming Concepts
Learning VB.NET Programming ConceptsLearning VB.NET Programming Concepts
Learning VB.NET Programming Concepts
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6
 
Data types
Data typesData types
Data types
 
UNIT-1(Lesson 5).pptx
UNIT-1(Lesson 5).pptxUNIT-1(Lesson 5).pptx
UNIT-1(Lesson 5).pptx
 
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdfCOMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
COMPUTER SCIENCE SUPPORT MATERIAL CLASS 12.pdf
 
enum_namespace.ppt
enum_namespace.pptenum_namespace.ppt
enum_namespace.ppt
 
Computer programming 2 Lesson 5
Computer programming 2  Lesson 5Computer programming 2  Lesson 5
Computer programming 2 Lesson 5
 
Data Type is a basic classification which identifies.docx
Data Type is a basic classification which identifies.docxData Type is a basic classification which identifies.docx
Data Type is a basic classification which identifies.docx
 

Mais de Dr. Rupinder Singh (8)

1.1 communication
1.1 communication1.1 communication
1.1 communication
 
Lesson 7 io statements
Lesson 7 io statementsLesson 7 io statements
Lesson 7 io statements
 
Lesson 4
Lesson 4Lesson 4
Lesson 4
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
Lesson 2
Lesson 2Lesson 2
Lesson 2
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
Compilation
CompilationCompilation
Compilation
 
C Slides
C SlidesC Slides
C Slides
 

Último

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Último (20)

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 

Data types

  • 1. DATA TYPES •Data types are used to define a variable before it can be used in a program. •C data types are defined as the data storage format that a variable can store a data to perform a specific operation.
  • 2. Data Types  Data Types is further divided into 3 parts. 1. Primitive 2. Derived 3. User Defined
  • 3.
  • 5. Integer Data Type  Integer data type allows a variable to store numeric values.  “int” keyword is used to refer integer data type.  The storage size of int data type is 2 bytes.  int (2 byte) can store values from -32,768 to +32,767  If you want to use the integer value that crosses the above limit, you can go for “long int” for which the limits are very high.
  • 6. General Syntax to declare int void main() { int a,b; // Here we have declared 2 integers } Each ‘a’ and ‘b’ will take 2 bytes each so 4 bytes will be stored in the memory
  • 7. Character  Character data type allows a variable to store only one character.  Storage size of character data type is 1. We can store only one character using character data type.  “char” keyword is used to refer character data type. Character takes only 1 byte and has a range from -128 to 127.  For example, ‘A’ can be stored using char datatype. You can’t store more than one character using char data type.
  • 8. General Syntax to declare Character void main() { char a,b; // Here we have declared 2 characters } Each ‘a’ and ‘b’ will take 1 byte each so 2 bytes will be stored in the memory
  • 9. Float Data Type  Float data type allows a variable to store decimal values.  Storage size of float data type is 4.  We can use up-to 6 digits after decimal using float data type.  For example, 10.456789 can be stored in a variable using float data type.  Range of Float is -3.4e38 to +3.4e38
  • 10. General Syntax to declare Float void main() { float a,b; // Here we have declared 2 float variables } Each ‘a’ and ‘b’ will take 4 bytes each so 8 bytes will be stored in the memory
  • 11. Double Data type  Double data type is also same as float data type which allows up-to 10 digits after decimal.  The range for double datatype is from 1E–37 to 1E+37.  It takes double the memory space as float. It takes 8 bytes.
  • 12. General Syntax to declare Float void main() { double a,b; // Here we have declared 2 double variables } Each ‘a’ and ‘b’ will take 8 bytes each so 16 bytes will be stored in the memory
  • 13. Void Data Type  Void is an empty data type that has no value.  This can be used in functions and pointers.  General Syntax void main() { }
  • 14. Enum  An enum is a keyword, it is an user defined data type. All properties of integer are applied on Enumeration data type so size of the enumerator data type is 2 byte. It work like the Integer.  It is used for creating an user defined data type of integer. Using enum we can create sequence of integer constant value.
  • 15. Syntax of enum  enum tagname {value1, value2, value3,....};  In above syntax enum is a keyword. It is a user defined data type.  In above syntax tagname is our own variable. tagname is any variable name.  value1, value2, value3,.... are create set of enum values.
  • 16. It is start with 0 (zero) by default and value is incremented by 1 for the sequential identifiers in the list. If constant one value is not initialized then by default sequence will be start from zero and next to generated value should be previous constant value one.
  • 17. Program of Enum #include<stdio.h> #include<conio.h> void main() { int a; enum ABC {x,y,z}; clrscr(); a=x+y+z; printf("Sum: %d",a); getch(); }
  • 18. Enum #include <stdio.h> #include<conio.h> void main() { int today; enum week{ sun,mon,tue,wed,thu,fri,sat}; clrscr(); today = wed; printf("Day %d",today+1); getch(); }