SlideShare a Scribd company logo
Datatypes
Datatypes
Datatypes
Example :-
When customer goes to a fruit vendor….
Need of Datatypes in programming
vendor: what do u want sir/madam.
Customer: I want apple. How much does it costs?
Vendor: How many do u want sir/madam.
Customer : Answers according to his/her requirement.which
is a variable x( which changes every time).
Vendor : Now he calculates the rate(c.p + profit) and sells the
apples.
In order to do this calculation in programming we need a thing
that can hold a value (a number like 5 or 20 etc)
That’s where we need
Variable and constant
Syntax of Datatypes in C
In the example:
• Number of apple he /she wanted. <value>
• Customer asked for apples. That identifies what he wants.
<identifier name>
• To store this value we need a box in programming which is a type
integer in C<type>
Format for Datatypes declaration and definition is :
<type> <identifier name>=<value>
Ex:
Int apples =20;
Types of Datatypes
Datatype Use to hold Example
int for integer range numbers -5
float for decimal range numbers 99.99
char for character numbers A
double for more precision decimal numbers 99.999999
* Long <datatype> for hold big numbers 34,333
* short <datatype> for value inside 32,768 8987
signed <datatype> **for only positive numbers 88
Unsigned<datatype> **for positive and negative numbers -96
•Except char Datatype.
•In char we have -128 t0 127 range for unsigned char and 0 to 255 for signed char
Sizeof
This will give u the size(int value) of the variable.
Syntax:-
sizeof(<identifier name>);
Example:-
int a,b;
b=sizeof(a);
Table of Datatypes
Type *Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes
-32,768 to 32,767 or -2,147,483,648
to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295
*Size depends on how many bit processor u r running on
Types of Datatypes(cont..)
Type Storage size Value range Precision
float 4 byte 1.2E-38 to 3.4E+38 6 decimal places
double 8 byte 2.3E-308 to 1.7E+308 15 decimal places
long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places
Printf advance…
Syntax:-
Printf(“<format string>”,<list of arguments>);
Format string:-
• %c char single character
• %d (%i) int signed integer
• %e (%E) float or double exponential format
• %f float or double signed decimal
• %g (%G) float or double use %f or %e as required
• %o int unsigned octal value
• %p pointer address stored in pointer
• %s array of char sequence of characters
• %u int unsigned decimal
• %x (%X) int unsigned hex value
Example:
Printf(“text %d”,apples);
Datatypes
Datatypes
Additional links
Website:-http://Sandeepedu65.blogspot.in
Youtube :-https://www.youtube.com/watch?v=_t0L462p930
Contact me:-
Email id:-ramsandeep1234@gmail.com

More Related Content

PPTX
Enumerated data types
PDF
Lesson 13. Pattern 5. Address arithmetic
PDF
June 04 P32
PDF
Lesson 9. Pattern 1. Magic numbers
PDF
Lesson 11. Pattern 3. Shift operations
PPTX
Introduction to Computing
PPT
05 multiply divide
PPTX
Typedef
Enumerated data types
Lesson 13. Pattern 5. Address arithmetic
June 04 P32
Lesson 9. Pattern 1. Magic numbers
Lesson 11. Pattern 3. Shift operations
Introduction to Computing
05 multiply divide
Typedef

Similar to Datatypes (20)

PPT
Unit 1 Built in Data types in C language.ppt
PPTX
Programming Fundamentals lecture 6
DOCX
PPTX
data types in C programming
PDF
cassignmentii-170424105623.pdf
PPTX
COM1407: Variables and Data Types
PPT
C language Unit 2 Slides, UPTU C language
PPT
Structured Programming with C - Data Types.ppt
PPT
Mesics lecture 3 c – constants and variables
PPTX
C Programming : data types and types of variable.pptx
PPTX
C language
PPTX
Data types slides by Faixan
PPTX
structured Programming Unit-2-Basic-Elements-of-C.pptx
PPTX
Module 1:Introduction
PPTX
chapxjkbjkxbkjbkxcbbcbcbbckbckter 1.pptx
PDF
[ITP - Lecture 05] Datatypes
PPTX
PDF
introduction to programming using ANSI C
PPTX
Data Type in C Programming
PPTX
Data types
Unit 1 Built in Data types in C language.ppt
Programming Fundamentals lecture 6
data types in C programming
cassignmentii-170424105623.pdf
COM1407: Variables and Data Types
C language Unit 2 Slides, UPTU C language
Structured Programming with C - Data Types.ppt
Mesics lecture 3 c – constants and variables
C Programming : data types and types of variable.pptx
C language
Data types slides by Faixan
structured Programming Unit-2-Basic-Elements-of-C.pptx
Module 1:Introduction
chapxjkbjkxbkjbkxcbbcbcbbckbckter 1.pptx
[ITP - Lecture 05] Datatypes
introduction to programming using ANSI C
Data Type in C Programming
Data types
Ad

Recently uploaded (20)

PPTX
20th Century Theater, Methods, History.pptx
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
International_Financial_Reporting_Standa.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
advance database management system book.pdf
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PDF
My India Quiz Book_20210205121199924.pdf
PDF
IGGE1 Understanding the Self1234567891011
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Hazard Identification & Risk Assessment .pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PPTX
Computer Architecture Input Output Memory.pptx
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
20th Century Theater, Methods, History.pptx
Environmental Education MCQ BD2EE - Share Source.pdf
International_Financial_Reporting_Standa.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
advance database management system book.pdf
Cambridge-Practice-Tests-for-IELTS-12.docx
My India Quiz Book_20210205121199924.pdf
IGGE1 Understanding the Self1234567891011
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
B.Sc. DS Unit 2 Software Engineering.pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Hazard Identification & Risk Assessment .pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
Computer Architecture Input Output Memory.pptx
Introduction to pro and eukaryotes and differences.pptx
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Ad

Datatypes

  • 4. Example :- When customer goes to a fruit vendor….
  • 5. Need of Datatypes in programming vendor: what do u want sir/madam. Customer: I want apple. How much does it costs? Vendor: How many do u want sir/madam. Customer : Answers according to his/her requirement.which is a variable x( which changes every time). Vendor : Now he calculates the rate(c.p + profit) and sells the apples. In order to do this calculation in programming we need a thing that can hold a value (a number like 5 or 20 etc) That’s where we need
  • 7. Syntax of Datatypes in C In the example: • Number of apple he /she wanted. <value> • Customer asked for apples. That identifies what he wants. <identifier name> • To store this value we need a box in programming which is a type integer in C<type> Format for Datatypes declaration and definition is : <type> <identifier name>=<value> Ex: Int apples =20;
  • 8. Types of Datatypes Datatype Use to hold Example int for integer range numbers -5 float for decimal range numbers 99.99 char for character numbers A double for more precision decimal numbers 99.999999 * Long <datatype> for hold big numbers 34,333 * short <datatype> for value inside 32,768 8987 signed <datatype> **for only positive numbers 88 Unsigned<datatype> **for positive and negative numbers -96 •Except char Datatype. •In char we have -128 t0 127 range for unsigned char and 0 to 255 for signed char
  • 9. Sizeof This will give u the size(int value) of the variable. Syntax:- sizeof(<identifier name>); Example:- int a,b; b=sizeof(a);
  • 10. Table of Datatypes Type *Storage size Value range char 1 byte -128 to 127 or 0 to 255 unsigned char 1 byte 0 to 255 signed char 1 byte -128 to 127 int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295 short 2 bytes -32,768 to 32,767 unsigned short 2 bytes 0 to 65,535 long 4 bytes -2,147,483,648 to 2,147,483,647 unsigned long 4 bytes 0 to 4,294,967,295 *Size depends on how many bit processor u r running on
  • 11. Types of Datatypes(cont..) Type Storage size Value range Precision float 4 byte 1.2E-38 to 3.4E+38 6 decimal places double 8 byte 2.3E-308 to 1.7E+308 15 decimal places long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places
  • 12. Printf advance… Syntax:- Printf(“<format string>”,<list of arguments>); Format string:- • %c char single character • %d (%i) int signed integer • %e (%E) float or double exponential format • %f float or double signed decimal • %g (%G) float or double use %f or %e as required • %o int unsigned octal value • %p pointer address stored in pointer • %s array of char sequence of characters • %u int unsigned decimal • %x (%X) int unsigned hex value Example: Printf(“text %d”,apples);