Question

Should variables that contain numbers always be declared as integer or floating-point data types? Why or...

Should variables that contain numbers always be declared as integer or floating-point data types? Why or why not? Name potential examples

Homework Answers

Answer #1

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:

  • char
  • short
  • int
  • long
  • float
  • double

• 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;

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Which of the following statements is false? a. Variables of type float represent single-precision floating-point numbers...
Which of the following statements is false? a. Variables of type float represent single-precision floating-point numbers and have seven significant digits b. Java provides two primitive types for storing floating-point numbers in memory—float and double c. A floating-point number is a number with a decimal point d. Variables of type double represent double-precision floating-point numbers; these require twice as much memory as float variables and provide 14 significant digits
Describe the reasons why techniques for parallel execution of integer operations do not always work well...
Describe the reasons why techniques for parallel execution of integer operations do not always work well for floating point arithmetic in MIPS
10. Number Array Class Design a class that has an array of floating-point numbers. The constructor...
10. Number Array Class Design a class that has an array of floating-point numbers. The constructor should accept an integer argument and dynamically allocate the array to hold that many numbers. The private data members of the class should include the integer argument in a variable to hold the size of the array and a pointer to float type to hold the address of the first element in the array. The destructor should free the memory held by the array....
** All floating point numbers should round up to 2 d.c. if necessary. 1. Given the...
** All floating point numbers should round up to 2 d.c. if necessary. 1. Given the information below: IL = 6 kd = 0.66 θ= 140 Calculate the resulting diffuse intensity by using Lambert's Law for Diffuse Reflection. Id =   * Do the calculation and round up at the last step to get the answer.
Q1: Answer the following questions about floating-point representations of real numbers: Why is normalization necessary? What...
Q1: Answer the following questions about floating-point representations of real numbers: Why is normalization necessary? What is the mantissa? After a number is normalized, what kind of information does a computer store in memory? Q2: A company has decided to assign a unique bit pattern to each employee. If thecompany has 900 employees, what is the minimum number of bits needed tocreate this system of representation? How many patterns are unassigned? If thecompany hires another 300 employees, should it increase...
Design a function called print_area that takes two floating-point numbers, representing the length and width of...
Design a function called print_area that takes two floating-point numbers, representing the length and width of a rectangle. The print_area function calculates and prints the area of the rectangle, rounded to two decimal places. Design a function called small_enough_word that takes a string for which the number of characters will be tested, and an integer representing the maximum allowable number of characters that the word can contain. Remember: the arguments MUST be in this order (the string of text before...
Leave comments on code describing what does what Objectives: 1. To introduce pointer variables and their...
Leave comments on code describing what does what Objectives: 1. To introduce pointer variables and their relationship with arrays 2. To introduce the dereferencing operator 3. To introduce the concept of dynamic memory allocation A distinction must always be made between a memory location’s address and the data stored at that location. In this lab, we will look at addresses of variables and at special variables, called pointers, which hold these addresses. The address of a variable is given by...
For the following description of​ data, identify the​ W's, name the​ variables, specify for each variable...
For the following description of​ data, identify the​ W's, name the​ variables, specify for each variable whether its use indicates it should be treated as categorical or​quantitative, and for any quantitative variable identify the units in which it was measured​ (or note that they were not​ provided). Specify whether the data come from a designed survey or experiment. Are the variables time series or​ cross-sectional? Report any concerns you have as well. A company provides ratings from customer experiences on...
Nominal data from the Latin 'name' is simply that a name. Republican, Democrat, Independent, etc. You've...
Nominal data from the Latin 'name' is simply that a name. Republican, Democrat, Independent, etc. You've no clue who you're voting for, or why, but you have a party name so that's something...right? To make this quantitative, you would assign each a random number of your choice (usually small sequential numbers like 1, 2, or 3 but it could be ANYthing). Since the value of the number has no meaning in your context, it's just a placeholder, you are very...
1. When presenting data graphically, you can choose from many types of graphics. Different graphic types,...
1. When presenting data graphically, you can choose from many types of graphics. Different graphic types, such as tables and charts, can be used to effectively highlight and depict different types of data in your report or presentation. As a professional communicator, you need to know which type of graphic is appropriate for different data. What type of graphic best illustrates changes in quantities over time? -Table -Line graph -Flow chart Read the scenario, and then answer the question. Sandeep...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT