Representing Data Types in C language www.tenouk.com, © 1/31 HOW CAN YOU SAY THAT A VARIABLE IS INTEGER? Integer - will hold values that are zero and positive and negative whole not numbers and should not contain decimal places. variables and constants integer data type, preceded by int. EXAMPLES: Const int Dozen = 12; Int score1, score2, score3; HOW CAN YOU THAT A VARIABLES IS CONSTANT FLOAT? Float- variables and constant float of data type, on the other hand can store real numbers that contain fractional parts. The value of float data type can have a precision of up to six decimal places and whose value may range 3.4 x 10 -38 to 3.4 x 10 38 By default, float constant are automatically treated as double precision during program execution. To prevent such conversion from taking place, use the suffix F or after the value of your constant float. www.tenouk.com, © 2/31 EXAMPLES of float Float salary; Const float price = 45.50f HOW CAN YOU TELL IF THE CONSTANT VARIABLE IS DOUBLE? Double - variables constant of this data type, can store values twice the precession of the float data type, thus the word double is used. It occupies two times of the memory as compared to that of float data type. It occupies two times of the memory as compared to that of float data type. Double RATE: 235.34554550; const double speed=446383.68789450; double distance; www.tenouk.com, © 2/31 HOW CAN SAY THE DECLARED VARIABLE IS CHARACTER? Character - variables constant of this type, usually preceded by char, can accept a single character enclosed by a pair of single quotation marks. ALSO, any number that is enclose to a pair of single and double quotation mark is considered data type char. Complete the following table by indicating the correct variable/constant, data type or declarations for each item. Variable/Constant data type declarations 1. a=17; int Int a=17; 2. ANS=‘y’ const char char cons ANS = ‘y’; 3. Price =533144.75 double double price=5333144.75; 4. Status [15]; char 5. X=1.9E-150 double char status [15]’; double X=1.9E-150 6. Bunos=50 const; int cons int bunos = 50; 7. Level=‘6’; char char level = ‘6’; Create a program that will allow you to enter test scores in four subject and compute the average using declaration of basic data type. #include<stdio.h> main() { int score1, score2,score3,score4; Double average, sum; printf(“Please type your test score 1 to 4 separated by spaces:”); scanf(“%d%d%d%d”, &score1,&score2,&score3,&score4); sum=score1+score2+score3+score4; average=sum/4; printf(“Your average scoe is %.2lf”, average); } End of the C data types www.tenouk.com, © 31/10