Should variables that contain numbers always be declared as integer or floating-point data types? Why or why not? Name potential examples
Should variables that contain numbers always be declared as integer or floating-point data types:
Answer: No. Variables that contain numbers can be declared other than integer or floating-point data types.
Description:
• Data types that can contain numeric values are:
• Example:
• Char data type can also contain numbers and that will return output as the ASCII value associated with that number.
Output:
Here, variable a will return ASCII value associated with number 80 that is P and variable b will return ASCII value associated with number 100 that is d.
• One can also declare numbers with following data type:
short a = 80;
long a = 80;
double b = 80.80;
long double b = 80.0080;
Get Answers For Free
Most questions answered within 1 hours.