IS130 Review Questions      

           

Savitch Chapter 2        

           

1          What is the value of the boolean variable answer if answer = 2?

2          Is a Boolean variable that is assigned the value 42 true or false?

3          What would be the result of assigning the following number (without the commas) in an integer variable?   37.587

4          Which data type can store larger numbers, int or double?

5          What are two advantages of using loop constructs in programming?

6          What are two of the major benefits of having branching in computer code?

7          What is the result of the following assignment if a has a current value of 10?  a += 3

8          Explain the difference in the number of times statements are executed in while loops versus do-while loops.

9          Why should we initialize variables before using them in a statement?

10        What does 8.76e3 signify in ordinary decimal notation?

11        List 5 different types of output devices.

12        What's the point of declaring a char variable?  Why would anyone want to store a single character in a char variable?

13        How would you indicate to the C++ compiler that you want to include the string "\n" (without the quotation marks) in an output statement?

14        If A has the value 20 then what is the value of A++?

15        List 5 different types of input devices.

16        Why do C++ programmers usually avoid using the NOT operator?

17        Why should you use parentheses when defining arithmetic expressions?

18        What is the result of dividing the two integer variables A and B if A = 5 and B = 2?

19        What is the peculiarity of integer division?

20        What programming error causes an infinite loop in a program?

21        What are two ways of showing several lines of comment at the start of a program?

22        Why shouldn't we use nice simple names like X or M as identifiers?

23        What's the danger in using the following identifiers in the same program:  name NAME Name?

24        What's the advantage of testing for an inequality in a Boolean expression used for the condition of a WHILE loop rather than testing for an equality?

25        Show the symbolic form of the condition "not equal to the value of the sum of variables A and B".

26        How can you make it less likely that a loop will be an infinite loop?

27        Would it be OK to use the following identifier for a variable in a C++ program?    "double"  Why or why not?