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
C Sharp Nagina (1)
PPT
C Sharp Jn (1)
PPTX
02. Primitive Data Types and Variables
PPTX
Datatypes & variables in java
PPTX
Visual Basic Fundamentals
PPT
Chapter 03
PPTX
Lesson 4 Basic Programming Constructs.pptx
PPTX
Data types slides by Faixan
PPT
02 Primitive data types and variables
PPTX
C programming language
PDF
About size_t and ptrdiff_t
PPTX
JAVA LESSON-01.pptx
PPTX
What are variables and keywords in c++
PPTX
Unit 1 introduction to visual basic programming
DOCX
Sql data types for various d bs by naveen kumar veligeti
PPT
programming week 2.ppt
PPT
Unit 1 Built in Data types in C language.ppt
PDF
Visual Basics for Application
C Sharp Nagina (1)
C Sharp Jn (1)
02. Primitive Data Types and Variables
Datatypes & variables in java
Visual Basic Fundamentals
Chapter 03
Lesson 4 Basic Programming Constructs.pptx
Data types slides by Faixan
02 Primitive data types and variables
C programming language
About size_t and ptrdiff_t
JAVA LESSON-01.pptx
What are variables and keywords in c++
Unit 1 introduction to visual basic programming
Sql data types for various d bs by naveen kumar veligeti
programming week 2.ppt
Unit 1 Built in Data types in C language.ppt
Visual Basics for Application
Ad

Recently uploaded (20)

PDF
African Communication Research: A review
PPTX
Thinking Routines and Learning Engagements.pptx
DOCX
Ibrahim Suliman Mukhtar CV5AUG2025.docx
PPT
REGULATION OF RESPIRATION lecture note 200L [Autosaved]-1-1.ppt
PDF
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
PDF
Civil Department's presentation Your score increases as you pick a category
PDF
M.Tech in Aerospace Engineering | BIT Mesra
PDF
semiconductor packaging in vlsi design fab
PDF
Journal of Dental Science - UDMY (2022).pdf
PPTX
UNIT_2-__LIPIDS[1].pptx.................
PDF
Farming Based Livelihood Systems English Notes
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
Everyday Spelling and Grammar by Kathi Wyldeck
PPTX
Integrated Management of Neonatal and Childhood Illnesses (IMNCI) – Unit IV |...
PDF
Literature_Review_methods_ BRACU_MKT426 course material
PPTX
Macbeth play - analysis .pptx english lit
PDF
Journal of Dental Science - UDMY (2020).pdf
PPTX
BSCE 2 NIGHT (CHAPTER 2) just cases.pptx
PDF
faiz-khans about Radiotherapy Physics-02.pdf
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
African Communication Research: A review
Thinking Routines and Learning Engagements.pptx
Ibrahim Suliman Mukhtar CV5AUG2025.docx
REGULATION OF RESPIRATION lecture note 200L [Autosaved]-1-1.ppt
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
Civil Department's presentation Your score increases as you pick a category
M.Tech in Aerospace Engineering | BIT Mesra
semiconductor packaging in vlsi design fab
Journal of Dental Science - UDMY (2022).pdf
UNIT_2-__LIPIDS[1].pptx.................
Farming Based Livelihood Systems English Notes
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
Everyday Spelling and Grammar by Kathi Wyldeck
Integrated Management of Neonatal and Childhood Illnesses (IMNCI) – Unit IV |...
Literature_Review_methods_ BRACU_MKT426 course material
Macbeth play - analysis .pptx english lit
Journal of Dental Science - UDMY (2020).pdf
BSCE 2 NIGHT (CHAPTER 2) just cases.pptx
faiz-khans about Radiotherapy Physics-02.pdf
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.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);