SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
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

Mais conteúdo relacionado

Destaque

C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS ConceptBoopathi K
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Lecture 03 Software Risk Management
Lecture 03 Software Risk ManagementLecture 03 Software Risk Management
Lecture 03 Software Risk ManagementAchmad Solichin
 
Characteristics of Software
Characteristics of SoftwareCharacteristics of Software
Characteristics of SoftwareUpekha Vandebona
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
Need for Software Engineering
Need for Software EngineeringNeed for Software Engineering
Need for Software EngineeringUpekha Vandebona
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9myrajendra
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language CourseVivek chan
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship ModelSlideshare
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).pptAlok Kumar
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic conceptsAbhinav Vatsa
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship DiagramShakila Mahjabin
 

Destaque (20)

C++ Language
C++ LanguageC++ Language
C++ Language
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Lecture 03 Software Risk Management
Lecture 03 Software Risk ManagementLecture 03 Software Risk Management
Lecture 03 Software Risk Management
 
Characteristics of Software
Characteristics of SoftwareCharacteristics of Software
Characteristics of Software
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Need for Software Engineering
Need for Software EngineeringNeed for Software Engineering
Need for Software Engineering
 
Dbms and sqlpptx
Dbms and sqlpptxDbms and sqlpptx
Dbms and sqlpptx
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
functions of C++
functions of C++functions of C++
functions of C++
 
Function in c
Function in cFunction in c
Function in c
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 

Semelhante a Data types

Semelhante a Data types (20)

Data types slides by Faixan
Data types slides by FaixanData types slides by Faixan
Data types slides by Faixan
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
C programming Ms. Pranoti Doke
C programming Ms. Pranoti DokeC programming Ms. Pranoti Doke
C programming Ms. Pranoti Doke
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
 
1.getting started with c
1.getting started with c1.getting started with c
1.getting started with c
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.ppt
 
Fuzzing - Part 1
Fuzzing - Part 1Fuzzing - Part 1
Fuzzing - Part 1
 
Java Datatypes
Java DatatypesJava Datatypes
Java Datatypes
 
Cp presentation
Cp presentationCp presentation
Cp presentation
 
Data type
Data typeData type
Data type
 
Datatypes & variables in java
Datatypes & variables in javaDatatypes & variables in java
Datatypes & variables in java
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1
 
Programming Basics.pptx
Programming Basics.pptxProgramming Basics.pptx
Programming Basics.pptx
 
Datatypes
DatatypesDatatypes
Datatypes
 

Mais de Learn By Watch

Demodulation of fm pll detector
Demodulation of fm pll detectorDemodulation of fm pll detector
Demodulation of fm pll detectorLearn By Watch
 
Demodulation of fm slope and balanced slope detector
Demodulation of fm slope and balanced slope detectorDemodulation of fm slope and balanced slope detector
Demodulation of fm slope and balanced slope detectorLearn By Watch
 
In direct method of fm generation armstrong method
In direct method of fm generation armstrong methodIn direct method of fm generation armstrong method
In direct method of fm generation armstrong methodLearn By Watch
 
Direct method of fm generation hartley oscillator method
Direct method of fm generation hartley oscillator methodDirect method of fm generation hartley oscillator method
Direct method of fm generation hartley oscillator methodLearn By Watch
 
Spectrum and power of wbfm
Spectrum and power of wbfmSpectrum and power of wbfm
Spectrum and power of wbfmLearn By Watch
 
Narrow band frequency modulation nbfm
Narrow band frequency modulation nbfmNarrow band frequency modulation nbfm
Narrow band frequency modulation nbfmLearn By Watch
 
General expression of fm signal
General expression of fm signalGeneral expression of fm signal
General expression of fm signalLearn By Watch
 
Frequency division multiplexing
Frequency division multiplexingFrequency division multiplexing
Frequency division multiplexingLearn By Watch
 
Demodulation of ssb synchronous detector
Demodulation of ssb synchronous detectorDemodulation of ssb synchronous detector
Demodulation of ssb synchronous detectorLearn By Watch
 
Generarion of ssb phase discrimination method
Generarion of ssb phase discrimination methodGenerarion of ssb phase discrimination method
Generarion of ssb phase discrimination methodLearn By Watch
 
Generarion of ssb frequency discrimination method
Generarion of ssb frequency discrimination methodGenerarion of ssb frequency discrimination method
Generarion of ssb frequency discrimination methodLearn By Watch
 
Demodulation of dsb sc costas receiver
Demodulation of dsb sc costas receiverDemodulation of dsb sc costas receiver
Demodulation of dsb sc costas receiverLearn By Watch
 
Quadrature carrier multiplexing qam
Quadrature carrier multiplexing qamQuadrature carrier multiplexing qam
Quadrature carrier multiplexing qamLearn By Watch
 
Demodulation of am synchronous detector
Demodulation of am synchronous detectorDemodulation of am synchronous detector
Demodulation of am synchronous detectorLearn By Watch
 

Mais de Learn By Watch (20)

Tutorial 9 fm
Tutorial 9 fmTutorial 9 fm
Tutorial 9 fm
 
Phase modulation
Phase modulationPhase modulation
Phase modulation
 
Demodulation of fm pll detector
Demodulation of fm pll detectorDemodulation of fm pll detector
Demodulation of fm pll detector
 
Demodulation of fm slope and balanced slope detector
Demodulation of fm slope and balanced slope detectorDemodulation of fm slope and balanced slope detector
Demodulation of fm slope and balanced slope detector
 
In direct method of fm generation armstrong method
In direct method of fm generation armstrong methodIn direct method of fm generation armstrong method
In direct method of fm generation armstrong method
 
Direct method of fm generation hartley oscillator method
Direct method of fm generation hartley oscillator methodDirect method of fm generation hartley oscillator method
Direct method of fm generation hartley oscillator method
 
Carson's rule
Carson's ruleCarson's rule
Carson's rule
 
Spectrum and power of wbfm
Spectrum and power of wbfmSpectrum and power of wbfm
Spectrum and power of wbfm
 
Narrow band frequency modulation nbfm
Narrow band frequency modulation nbfmNarrow band frequency modulation nbfm
Narrow band frequency modulation nbfm
 
General expression of fm signal
General expression of fm signalGeneral expression of fm signal
General expression of fm signal
 
Angle modulation
Angle modulationAngle modulation
Angle modulation
 
Frequency division multiplexing
Frequency division multiplexingFrequency division multiplexing
Frequency division multiplexing
 
Vsb modulation
Vsb modulationVsb modulation
Vsb modulation
 
Demodulation of ssb synchronous detector
Demodulation of ssb synchronous detectorDemodulation of ssb synchronous detector
Demodulation of ssb synchronous detector
 
Generarion of ssb phase discrimination method
Generarion of ssb phase discrimination methodGenerarion of ssb phase discrimination method
Generarion of ssb phase discrimination method
 
Generarion of ssb frequency discrimination method
Generarion of ssb frequency discrimination methodGenerarion of ssb frequency discrimination method
Generarion of ssb frequency discrimination method
 
Ssb modulation
Ssb modulationSsb modulation
Ssb modulation
 
Demodulation of dsb sc costas receiver
Demodulation of dsb sc costas receiverDemodulation of dsb sc costas receiver
Demodulation of dsb sc costas receiver
 
Quadrature carrier multiplexing qam
Quadrature carrier multiplexing qamQuadrature carrier multiplexing qam
Quadrature carrier multiplexing qam
 
Demodulation of am synchronous detector
Demodulation of am synchronous detectorDemodulation of am synchronous detector
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