Data types

1,615 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,615
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
72
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Data types

  1. 1. C Programming Language By: Yogendra Pal yogendra@learnbywatch.com Dedicated to My mother and Father
  2. 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. 3. Introduction • You learned about three primary data types – char – int – float • These primary data types can be of several types.
  4. 4. Integer long & short signed & unsigned
  5. 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. 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. 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. 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. 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. 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. 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
  12. 12. character
  13. 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. 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. 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. 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. 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

×