Review Questions and Answers PART A A1 1. Computers can do many different jobs b
ID: 3687552 • Letter: R
Question
Review Questions and Answers PART A
A1
1. Computers can do many different jobs because they can be __________.
2. The job of the __________ is to fetch instructions, carry out the operations commanded by the instructions, and produce some outcome or resultant information.
3. Internally, the CPU consists of the __________ and the __________.
4. A(n) __________ is an example of a secondary storage device.
5. The two general categories of software are __________ and __________.
6. A program is a set of __________.
7. Since computers can’t be programmed in natural human language, algorithms must be written in a(n) __________ language.
8. __________ is the only language computers really process.
9. __________ languages are close to the level of humans in terms of readability.
10. __________ languages are close to the level of the computer.
11. A program’s ability to run on several different types of computer systems is called __________.
12. Words that have special meaning in a programming language are called __________ words.
13. Words or names defined by the programmer are called __________.
14. __________ are characters or symbols that perform operations on one or more operands.
15. __________ characters or symbols mark the beginning or ending of programming statements, or separate items in a list.
16. The rules that must be followed when constructing a program are called __________.
17. A(n) __________ is a named storage location.
18. A variable must be __________ before it can be used in a program.
19. The three primary activities of a program are __________, __________, and __________.
20. __________ is information a program gathers from the outside world
21. __________ is information a program sends to the outside world.
22. A(n) __________ is a diagram that graphically illustrates the structure of a program.
23. Both main memory and secondary storage are types of memory. Describe the differ- ence between the two.
24. What is the difference between operating system software and application software?
25. What is the difference between a syntax error and a logical error?
A2
1. Every complete statement ends with a __________.
2. To use cout statements you must include the __________ file in your program.
3. Every C++ program must have a function named __________.
4. Preprocessor directives begin with a __________.
5. A group of statements, such as the body of a function, must be enclosed in __________.
6. 72, 'A', and "Hello World" are all examples of __________.
7. 978.65 × 1012 would be written in E notation as __________.
8. The character constant 'A' requires __________ byte(s) of memory, whereas the string constant "A" requires __________ byte(s).
9. Which of the following are not valid assignment statements?
A) total = 9; B) 72 = amount; C) yourAge = myAge;
10. If the variable letter has been defined as a char variable, which of the following are not valid assignment statements?
A) letter = w; B) letter = 'w'; C) letter = "w";
11. Which of the following are not valid cout statements?
A) cout << "Hello" << endl; B) cout << "Hello" << ; C) cout << Hello;
12. Which of the following are not valid cout statements?
A) cout << "Hello world"; B) cout << Hello world; C) cout << "Hello" << " world";
13. Assume x = 4, y = 7, and z = 2. What value will be stored in integer variable result by each of the following statements?
A) result = x + y; B) result = y * 2; C) result = y / z;
14. Assume x = 2.5, y = 7.0, and z = 3. What value will be stored in integer variable result by each of the following statements?
A) result = x + y; B) result = y * 2; C) result = y / z;
15. Write a C++ statement that defines the double variables temp, weight, and height all in the same statement.
16. Write a C++ statement that defines the int variables months, days, and years all in the same statement, with months initialized to 2 and years initialized to 3.
17. Write assignment statements that perform the following operations with int variable i, double variables d1 and d2, and char variable c.
A) Add 2 to d1 and store the result in d2.
B) Multiply d2 time 4 and store the result in d1.
C) Store the character 'K' in c.
D) Store the ASCII code for the character 'K' in i.
E) Subtract 1 from i and store the result back in i.
18. Write assignment statements that perform the following operations with int variable i, double variables d1 and d2, and char variable c.
A) Subtract 8.5 from d2 and store the result in d1.
B) Divide d1 by 3.14 and store the result in d2.
C) Store the ASCII code for the character 'F' in c.
D) Add 1 to i and store the new value back in i.
E) Add d1 to the current value of d2 and store the result back in d2 as its new value.
19. Modify the following program segment so it prints two blank lines between each line of text.
cout << "Two mandolins like creatures in the";
cout << "dark"; cout << "Creating the agony of ecstasy.";
cout << " - George Barker";
A3
1. Assume a string object has been defined as follows: string description;
A) Write a cin statement that reads in a one word description.
B) Write a statement that reads in a description that can contain multiple words separated by blanks.
2. Write a definition statement for a character array large enough to hold any of the following strings:
"Billy Bob's Pizza"
"Downtown Auto Supplies"
"Betty Smith School of Architecture"
"ABC Cabinet Company"
3. Assume the array name is defined as follows: char name[25];
A) Using a stream manipulator, write a cin statement that will read a string into name, but will read no more characters than name can hold.
B) Using the getline function, write a cin statement that will read a string into name but that will read no more characters than name can hold.
4. Assume the following variables are defined: int age; double pay; char section;
Write a single cin statement that will read input into each of these variables.
5. What header files must be included in the following program?
int main()
{
double amount = 89.7;
cout << fixed << showpoint << setprecision(1); cout << setw(8) << amount << endl;
return 0;
}
6. Write a definition statement for a character array named city. It should be large
enough to hold a string 30 characters in length.
7. Assume the following preprocessor directive appears in a program:
#define SIZE 12
How will the preprocessor rewrite the following lines?
A) price = SIZE * unitCost; B) cout << setw(SIZE) << 98.7; C) cout << SIZE;
8. Complete the following table by writing the value of each expression in the Value column.
Expression Value
28 / 4 - 2
6 + 12 * 2 - 8
4+8* 2 6 + 17 % 3 - 2
2 + 22 * (9 - 7)
(8 + 7) * 2 (16 + 7) % 2 - 1
12 / (10 - 6)
(19 - 3) * (2 + 2) / 4
9. Write C++ expressions for the following algebraic expressions:
A) a=12x
B) z = 5x+14y + 6k
C) y = x4
D) g = h + 12
4k
E) c = a3
b2k4
10. Assume a program has the following variable definitions:
int units; float mass; double weight;
and the following statement: weight = mass * units;
Which automatic data type conversions will take place?
11. Assume a program has the following variable definitions
int a, b = 2; double c = 4.3; and the following statement: a = b * c;
What value will be stored in a?
12. Assume that qty and salesReps are both integers.
Use a type cast expression to rewrite the following statement so it will no longer perform integer division.
unitsEach = qty / salesReps;
13. Rewrite the following variable definition so the variable is a named constant with the value 12. int rate;
14, 15 are deliberately missing.
16. Replace the following statements with a single statement that initializes sum to 0 at the time it is defined.
int sum;
sum = 0;
17. Is the following code legal? Why or why not?
const int DAYS_IN_WEEK; DAYS_IN_WEEK = 7;
18,19 are deliberately missing.
20. What header file must be included
A) to perform mathematical functions like sqrt?
B) to use files?
C) to use stream manipluators like setprecision?
Explanation / Answer
A1
1. Programmed
2. CPU
3. Control Unit and Arithmetic Logic Unit
4. Hard Disk
5. Operating System software ,Application software
6. Instructions
7. Programming
8. Machine Language
9. High level
10. Low level
11. Portability
12. Key Words
13. Programmer-defined symbols
14. Operators
15. Punctuation
16. Syntax
17. Variable
18. Defined
19. Input,Processing and Output
20. Input
21. Output
22. Hierarchy Chart
23. main memory would refer to the system RAM, a relatively fast portion of memory directly manipulated by the processor.Secondary memory refers the storage medium like Hard drives,disk,etc.
24. Operating System is the system software that makes the computer work. It acts as an Interface between you and hardware. Application software is the software that you install onto your Operating system.It consists of programs that actually let you do things with your computer,These Applications are written to run under the various Operating Systems.
25. Syntax error occurs when the code isn't formated or typed correctly.i.e in Phython, typing If instead of if because t only recognizes lowercase. Logical error occurs when there is a fallacy of reasoning.i.e In Phython, typing if x<0 and x>5.Since a value can't be less than 0 and greater than 5, a logical error will occur.
A2
1. Semicolon(;)
2. iostream library
3. main
4. #
5. curly braces
6. Literals or constants
9.B)72 = amount;
valid statement is amount = 72;
10.C)letter="w";
Because double quotes are used for only String variable declaration.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.