SlideShare a Scribd company logo
C             Programming
                       Language
               By:
    Yogendra Pal
yogendra@learnbywatch.com
  Dedicated to My mother and Father
Keep your notebook with you.

Write important point and questions that comes in your mind

     Solve Mind band exercise.
                                     Rewind when not clear


              Ask Questions by call or SMS or by mail


Keep Watching Keep Learning

THIS IS DATA TYPES
Introduction
• You learned about three primary data types
  – char
  – int
  – float
• These primary data types can be of several
  types.
Integer
long & short       signed & unsigned
long and short
• Integer
  – On 16-bit OS : 2 Bytes
  – On 32-bit OS : 4 Bytes
• When we declare an integer it occupies 4 bytes
  on a 32 bit OS.
• Sometimes it may be more than required.
• Why waste memory?
• How to save?
short integer
• Declare a short integer.
           short int a; //OR
           short b;
•   It will take at least 2 bytes.
•   You will save 2 bytes.
•   shorts are never bigger than ints.
•   Format specifier : %d
long integer
• Declare a long integer.
           long int a; //OR
           long b;
•   It will take at least 4 bytes.
•   Helpful if you are working on 16-bit OS.
•   ints are never bigger than longs.
•   Format specifier : %ld
signed and unsigned
• Value stored in an integer is positive by default.
• In a 16 bit OS the range for an integer will be:
                    -32768 to 32767
• Some times we do not need negative value.
• Why waste half of the values???
• Use signed and unsigned variable in this case.
unsigned integer
• Declare a unsigned integer.
          unsigned int a; //OR
          unsigned b;
• It will store in 2 bytes on 16-bit OS.
• Range will be : 0 to 65535
• Format specifier : %u
signed integer
• Declare a signed integer.
          signed int a; //OR
          signed b; //OR
          int c;
• It will store in 2 bytes on 16-bit OS.
• Range will be : -32768 to 32767
• Format specifier : %d
integers
Data type            Range                       Bytes   Format
short signed int     -32768 to 32767             2       %d
short unsigned int   0 to 65535                  2       %u
signed int           -2147483648 to 2147483648   4       %d
unsigned int         0 to 4294967295             4       %u
long signed int      -2147483648 to 2147483648   4       %ld
long unsigned int    0 to 4294967295             4       %lu
character
character
• Character range : -128 to 127
            signed char c; //OR
            char c1;
•   128 means -128 in case of character.
•   129 means -127
•   unsigned character range : 0 to 255
•   Hence it will print all 256 available characters.
            unsigned char c;
float and double
• Both are used for storing floating point value.
• float occupies 4 bytes and it’s range is:-
  – -3.4e38 to +3.4e38
  – Format specifier : %f
• double occupies 8 bytes and it’s range is:-
  – -1.7e308 to +1.7e308
  – Format specifier : %lf
       double a;
long double
• If your demand is too high you can use it.
• long double occupies 10 bytes and it’s range is:
  – -1.7e4932 to +1.7e4932
  – Format specifier : %Lf
       long double a;
floating point
Data type     Range                    Bytes   Format
float         -3.4e38 to +3.4e38       4       %f
double        -1.7e308 to +1.7e308     8       %lf
long double   -1.7e4932 to +1.7e4932   10      %Lf
To get complete benefit of this tutorial solve all the quiz on
                       www.learnbywatch.com

               For any problem in this tutorial mail me at
                     yogendra@learnbywatch.com
                         with the subject “C”

                     For Other information mail at
                       info@learnbywatch.com
From Here To

STORAGE CLASS

More Related Content

PPTX
A Closer Look at Data Types, Variables and Expressions
PPTX
Data types in c language
PPTX
Digital logic designing presentation
DOC
Data type
PPTX
Lecture 2 variables
PPTX
Binary codes
PPTX
Digital principles basic
PPTX
Variables in C and C++ Language
A Closer Look at Data Types, Variables and Expressions
Data types in c language
Digital logic designing presentation
Data type
Lecture 2 variables
Binary codes
Digital principles basic
Variables in C and C++ Language

Viewers also liked (20)

PPT
C++ Language
PDF
C++ OOPS Concept
PPT
Basics of c++ Programming Language
ODP
C++ Function
PPTX
Lecture 03 Software Risk Management
PPTX
Characteristics of Software
PPTX
C Language (All Concept)
PPS
C++ Language
PPTX
Need for Software Engineering
PPTX
Dbms and sqlpptx
PPT
Operating system services 9
PPT
C++ Function
PPSX
Complete C programming Language Course
PPTX
Entity Relationship Model
PPTX
OOPS IN C++
PPTX
Oop c++class(final).ppt
PPTX
functions of C++
PPTX
Function in c
PPT
C the basic concepts
PPT
Entity Relationship Diagram
C++ Language
C++ OOPS Concept
Basics of c++ Programming Language
C++ Function
Lecture 03 Software Risk Management
Characteristics of Software
C Language (All Concept)
C++ Language
Need for Software Engineering
Dbms and sqlpptx
Operating system services 9
C++ Function
Complete C programming Language Course
Entity Relationship Model
OOPS IN C++
Oop c++class(final).ppt
functions of C++
Function in c
C the basic concepts
Entity Relationship Diagram
Ad

Similar to Data types (20)

PPT
Mesics lecture 3 c – constants and variables
PPTX
Lecture 2 introduction to Programming languages C.pptx
PDF
[ITP - Lecture 05] Datatypes
PPTX
Data types slides by Faixan
PPT
Datatypes
PPTX
Ch7 Basic Types
PPT
Lec 08. C Data Types
PPT
C tutorial
PDF
2 1. variables & data types
PPT
FP 201 Unit 2 - Part 2
PPT
C language Unit 2 Slides, UPTU C language
PDF
C Programming Assignment
PPTX
Data types
PPTX
Learn C LANGUAGE at ASIT
PPTX
Constant, variables, data types
PPS
C programming session 01
PPSX
C language (Collected By Dushmanta)
PPT
Data Types in C
DOCX
C cheat sheet for varsity (extreme edition)
Mesics lecture 3 c – constants and variables
Lecture 2 introduction to Programming languages C.pptx
[ITP - Lecture 05] Datatypes
Data types slides by Faixan
Datatypes
Ch7 Basic Types
Lec 08. C Data Types
C tutorial
2 1. variables & data types
FP 201 Unit 2 - Part 2
C language Unit 2 Slides, UPTU C language
C Programming Assignment
Data types
Learn C LANGUAGE at ASIT
Constant, variables, data types
C programming session 01
C language (Collected By Dushmanta)
Data Types in C
C cheat sheet for varsity (extreme edition)
Ad

More from Learn By Watch (20)

PPTX
Tutorial 9 fm
PPTX
Phase modulation
PPTX
Demodulation of fm pll detector
PPTX
Demodulation of fm slope and balanced slope detector
PPTX
In direct method of fm generation armstrong method
PPTX
Direct method of fm generation hartley oscillator method
PPTX
Carson's rule
PPTX
Spectrum and power of wbfm
PPTX
Narrow band frequency modulation nbfm
PPTX
General expression of fm signal
PPTX
Angle modulation
PPTX
Frequency division multiplexing
PPTX
Vsb modulation
PPTX
Demodulation of ssb synchronous detector
PPTX
Generarion of ssb phase discrimination method
PPTX
Generarion of ssb frequency discrimination method
PPTX
Ssb modulation
PPTX
Demodulation of dsb sc costas receiver
PPTX
Quadrature carrier multiplexing qam
PPTX
Demodulation of am synchronous detector
Tutorial 9 fm
Phase modulation
Demodulation of fm pll detector
Demodulation of fm slope and balanced slope detector
In direct method of fm generation armstrong method
Direct method of fm generation hartley oscillator method
Carson's rule
Spectrum and power of wbfm
Narrow band frequency modulation nbfm
General expression of fm signal
Angle modulation
Frequency division multiplexing
Vsb modulation
Demodulation of ssb synchronous detector
Generarion of ssb phase discrimination method
Generarion of ssb frequency discrimination method
Ssb modulation
Demodulation of dsb sc costas receiver
Quadrature carrier multiplexing qam
Demodulation of am synchronous detector

Data types

  • 1. C Programming Language By: Yogendra Pal yogendra@learnbywatch.com Dedicated to My mother and Father
  • 2. Keep your notebook with you. Write important point and questions that comes in your mind Solve Mind band exercise. Rewind when not clear Ask Questions by call or SMS or by mail Keep Watching Keep Learning THIS IS DATA TYPES
  • 3. Introduction • You learned about three primary data types – char – int – float • These primary data types can be of several types.
  • 4. Integer long & short signed & unsigned
  • 5. long and short • Integer – On 16-bit OS : 2 Bytes – On 32-bit OS : 4 Bytes • When we declare an integer it occupies 4 bytes on a 32 bit OS. • Sometimes it may be more than required. • Why waste memory? • How to save?
  • 6. short integer • Declare a short integer. short int a; //OR short b; • It will take at least 2 bytes. • You will save 2 bytes. • shorts are never bigger than ints. • Format specifier : %d
  • 7. long integer • Declare a long integer. long int a; //OR long b; • It will take at least 4 bytes. • Helpful if you are working on 16-bit OS. • ints are never bigger than longs. • Format specifier : %ld
  • 8. signed and unsigned • Value stored in an integer is positive by default. • In a 16 bit OS the range for an integer will be: -32768 to 32767 • Some times we do not need negative value. • Why waste half of the values??? • Use signed and unsigned variable in this case.
  • 9. unsigned integer • Declare a unsigned integer. unsigned int a; //OR unsigned b; • It will store in 2 bytes on 16-bit OS. • Range will be : 0 to 65535 • Format specifier : %u
  • 10. signed integer • Declare a signed integer. signed int a; //OR signed b; //OR int c; • It will store in 2 bytes on 16-bit OS. • Range will be : -32768 to 32767 • Format specifier : %d
  • 11. integers Data type Range Bytes Format short signed int -32768 to 32767 2 %d short unsigned int 0 to 65535 2 %u signed int -2147483648 to 2147483648 4 %d unsigned int 0 to 4294967295 4 %u long signed int -2147483648 to 2147483648 4 %ld long unsigned int 0 to 4294967295 4 %lu
  • 13. character • Character range : -128 to 127 signed char c; //OR char c1; • 128 means -128 in case of character. • 129 means -127 • unsigned character range : 0 to 255 • Hence it will print all 256 available characters. unsigned char c;
  • 14. float and double • Both are used for storing floating point value. • float occupies 4 bytes and it’s range is:- – -3.4e38 to +3.4e38 – Format specifier : %f • double occupies 8 bytes and it’s range is:- – -1.7e308 to +1.7e308 – Format specifier : %lf double a;
  • 15. long double • If your demand is too high you can use it. • long double occupies 10 bytes and it’s range is: – -1.7e4932 to +1.7e4932 – Format specifier : %Lf long double a;
  • 16. floating point Data type Range Bytes Format float -3.4e38 to +3.4e38 4 %f double -1.7e308 to +1.7e308 8 %lf long double -1.7e4932 to +1.7e4932 10 %Lf
  • 17. To get complete benefit of this tutorial solve all the quiz on www.learnbywatch.com For any problem in this tutorial mail me at yogendra@learnbywatch.com with the subject “C” For Other information mail at info@learnbywatch.com From Here To STORAGE CLASS