[Solved] : Question 13893

Write a declaration statement to declare that the variable count will be used to store an integer.
b. Write a declaration statement to declare that the variable volt will be used to store a floating-point number.
c. Write a declaration statement to declare that the variable power will be used to store a double-precision number.
d. Write a declaration statement to declare that the variable keychar will be used to store a character.

4. (Practice) Write declaration statements for the following variables:
a. num1, num2, and num3 used to store integer number
b. amps1, amps2, amps3, and amps4 used to store double-precision numbers
c. volts1, volts2, and volts3 used to store double-precision numbers
d. codeA, codeB, codeC, codeD, and codeE used to store characters

5. (Practice) Write declaration statements for the following variables:
a. firstnum and secnum used to store integer
b. speed, acceleration, and distance used to store double-precision numbers
c. thrust used to store a double-precision number

6. (Modify) Rewrite each of these declaration statements as three separate declarations:
a. int month, day = 30, year;
b. double hours, volt, power = 15.62;
c. double price, amount, taxes;
d. char inKey, ch, choice = ‘f’;

7. (Desk Check) a. Determine what each statement causes to happen in the following program:

#include
using namespace std;

int main()
{
int num1, num2, total;

num1 = 25;
num2 = 30;
total = num1 + num2;
cout << “The total of ” << num1 << ” and “
<< num2 << ” is ” << total << endl;

return 0;
}
b. What output will be printed when the program in Exercise 7a runs?

8. (Practice) What are the three items associated with every variable?

NNote for Exercises 9 to 11: Assume that a character requires 1 byte of storage, an integer requires
O T4 bytes, a single-precision number requires 4 bytes, and a double-precision number requires 8
Ebytes. Variables are assigned storage in the order they’re declared. (Review Section 1.6 if you’re
unfamiliar with the concept of a byte.) Refer to Figure 2.14 for these exercises.

Addresses

159 160161 162163164165166

167 168169 170171172173174

175 176177 178179180181182

183 184185 186187188189190

Figure 2.14 Memory bytes for Exercises 9 to 11

9. (Practice) a. Using Figure 2.14 and assuming the variable name rate is assigned to the byte at memory address 159, determine the addresses corresponding to each variable declared in the following statements. Also, fill in the correct number of bytes with the initialization data included in the declaration statements. (Use letters for the characters, not the computer codes that would actually be stored.)

float rate;
char ch1 = ‘M’, ch2 = ‘E’, ch3 = ‘L’, ch4 = ‘T’;
double taxes;
int num, count = 0;
b. Repeat Exercise 9a, but substitute the actual byte patterns that a computer using the ASCII code would use to store characters in the variables ch1, ch2, ch3, and ch4. (Hint: Use Appendix B.)

10. (Practice) a. Using Figure 2.14 and assuming the variable named cn1 is assigned to the byte at memory address 159, determine the addresses corresponding to each variable declared in the following statements. Also, fill in the correct number of bytes with the initialization data included in the declaration statements. (Use letters for the characters, not the computer codes that would actually be stored.)

char cn1 = ‘P’, cn2 = ‘E’, cn3 = ‘R’, cn4 = ‘F’, cn5 = ‘E’; char cn6 = ‘C’, cn7 = ‘T’, key = ”, sch = ”’, inc = ‘A’; char inc1 = ‘T’;
b. Repeat Exercise 10a, but substitute the actual byte patterns a computer using the ASCII
code would use to store characters in each of the declared variables. (Hint: Use Table 2.3.)

11. (Practice) Using Figure 2.14 and assuming the variable name miles is assigned to the byte at memory address 159, determine the addresses corresponding to each variable declared in the following statements:

float miles;
int count, num;
double dist, temp;


Expert Answer


Answer to : Question 13893

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?