Lab02-DataTypes

7
ICS 103: Computer Programming in C Lab #02: Data Types Objectie: Learn about Basic data types in C and how to use them in Problem Solving !asic Data types in C The following table shows the basic data types in C: Data Ty pe C "eyor$ !ytes %ange P&ace'o&$er (print)* P&ace'o&$er (scan)* Character char 1 -1! to 1" # c # c $nteger int % -&1%"&%!'&(%! to &1%"&%!'&(%" #d #d )loating Point float % -'*%+'! to '*% +'! #f #f  ,ouble precession floating point* double ! -1*"e'! to 1*"e.'! #f #lf  +otes: 1* C als o def in es the fol lowi ng modifiers that can be used to modif y th e memory al located to the types above as well as the range of possible values: short long signed unsigned )or e/ample& short int 0or simply s'ort reduces the si2e allocated to integers to bytes with a rage of 0-'&"(! to '&"("* The default for char  and int  is signed 3 meaning the values are distributed between negative and  positive v alues* unsigne$ c'ar will allocate all the possible range to positive values 0 to 44*  * The standard C specification 056S$ C does not ac tually specify a fi/ed range or memory for these types* 5ll it says is something li7e this:  short int 89 int 89 long int  float 89 double 89 long double  hat this means is that a s'ort int should assign less than or the same amount of  storage as an int and the int should be less or the same bytes as a &ong int* Thus& the above ranges are actually machine and implementation dependent* The following e/ample will print the actual si2e allocated based on your computer: ;< ,isplays the number of bytes used to store each basic type <;

Transcript of Lab02-DataTypes

8/10/2019 Lab02-DataTypes

http://slidepdf.com/reader/full/lab02-datatypes 1/7

8/10/2019 Lab02-DataTypes

http://slidepdf.com/reader/full/lab02-datatypes 2/7

8/10/2019 Lab02-DataTypes

http://slidepdf.com/reader/full/lab02-datatypes 3/7

8/10/2019 Lab02-DataTypes

http://slidepdf.com/reader/full/lab02-datatypes 4/7

8/10/2019 Lab02-DataTypes

http://slidepdf.com/reader/full/lab02-datatypes 5/7

8/10/2019 Lab02-DataTypes

http://slidepdf.com/reader/full/lab02-datatypes 6/7

8/10/2019 Lab02-DataTypes

http://slidepdf.com/reader/full/lab02-datatypes 7/7