Presentation is loading. Please wait.

Presentation is loading. Please wait.

CISC105 – General Computer Science Class 9 – 07/03/2006.

Similar presentations


Presentation on theme: "CISC105 – General Computer Science Class 9 – 07/03/2006."— Presentation transcript:

1 CISC105 – General Computer Science Class 9 – 07/03/2006

2 Numeric Data Types Integer can be represented by various data types in C and are stored as binary values –int (16 bits – 15 bits for value 1 for sign): -32,767 to 32,767 –unsigned (16 bits): 0 to 65,535 –long (32 bits – 31 for value, 1 for sign): -2,147,483,647 to 2,147,483,647 –unsigned long (32 bits): 0 to 4,294,967,295

3 Numeric Data Types Floating-point Types are stored in memory by using a mantissa and exponent value such that real_number = mantissa x 2 exponent –float : 10 -37 to 10 38 with 6 significant digits –double : 10 -307 to 10 308 with 15 significant digits –long double : 10 -4931 to 10 4932 with 19 significant digits –See doublePrecision.c doublePrecision2.cdoublePrecision.cdoublePrecision2.c

4 Automatic Data Type Conversion int + double; returns a double double = int; the int is converted to a double int = double; the double is converted to an int and the fractional part is lost See datatypeConversion.cdatatypeConversion.c

5 Explicit Type Cast You can explicitly cast data types as well. See typecast.ctypecast.c

6 Character Types The char data type can be represented as a character or by it’s ASCII numeric value. See printASCII.cprintASCII.c

7 Enumerated Types An enumerated type is a list of values that is specified by the programmer in type declaration Enumeration constant is an identifier that is one of the values of the enumerated type. See enumeratedTypes.cenumeratedTypes.c

8 Arrays An array is a collection of values of the same type. An array is a Data Structure –Data Structure – is a composite of related data items stored under the same name

9 Declaring Arrays An Array is declared by listing the type variable_name[number_of_elements] –int grades[5]; –double income_for_month[12]; –char name[15];

10 Accessing Elements To access the elements in an array you use the array name and the subscript –grade[1]; –income_for_month[5]; –See array1.c array2.carray1.carray2.c


Download ppt "CISC105 – General Computer Science Class 9 – 07/03/2006."

Similar presentations


Ads by Google