Answer to Question #13893 in C++ for mitos

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?

N Note for Exercises 9 to 11: Assume that a character requires 1 byte of storage, an integer requires
O T 4 bytes, a single-precision number requires 4 bytes, and a double-precision number requires 8
E bytes. 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 160 161 162 163 164 165 166


167 168 169 170 171 172 173 174


175 176 177 178 179 180 181 182


183 184 185 186 187 188 189 190


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;
1
Expert's answer
2012-08-30T08:21:27-0400
Unfortunately, your question requires a lot of work and cannot be done for free.
Submit it with all requirements as an assignment to our control panel and we'll assist you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS