What data type would you use to represent the following items? (a) the average marks in a class. (b) A letter grade on an exam. (c) The average marks of your class.
Answers
Answer:
a)float b)char c)float
Answer:
(a) the average marks in a class.
Float Data Type
(b) A letter grade on an exam.
Character Data Type
(c) The average marks of your class.
Float Data Type
Explanation:
Data Types
Data types are used to show which value can be accepted by a variable. Like integer data type can accept only whole numbers. Any other value will cause a type error.
There are different types of data types available in each programming language. Let's discuss the above three mentioned data types:
Float Data Type
The float data type is used to store decimal point numbers.
For example: 25.85, 7.9, 2.1 etc
The size of the float is 4 bytes in C language. It might be possible that average marks in the class may contain decimal points so to store it float a data type is a perfect option.
Character Data Type
To store only a single character, we can use the char data type. It occupies only 1 byte in the memory.
For example: 'A', 'B', 'C' etc.
Integer Data Type
It is used to store the whole number. That means the numbers which don't have decimal points.
Like 1,2,3,752,85 etc. It occupies 4 bytes in the memory.
#SPJ2