Thursday 26 March 2015

Questions and Answers of OOP Assignment

SUBMISSION DATE : 28th March , 2015

NOTE : Assignment should be hand written.


Questions of OOP Assignment:


1. Dividing a program into functions
a. is the key to object-oriented programming.
b. makes the program easier to conceptualize.
c. may reduce the size of the program.
d. makes the program run faster.

2. A function name must be followed by ________.

3. A function body is delimited by ________.

4. Why is the main() function special?

5. A C++ instruction that tells the computer to do something is called a ________.

6. Write an example of a normal C++ comment and an example of an old-fashioned /* comment.

7. An expression
a. usually evaluates to a numerical value.
b. indicates the emotional state of the program.
c. always occurs outside a function.
d. may be part of a statement.

8. Specify how many bytes are occupied by the following data types in a 32-bit system:
a. Type int
b. Type long double
c. Type float
d. Type long

9. True or false:
A variable of type char can hold the value 301.

10. What kind of program elements are the following?
 a. 12
b. ‘a’
c. 4.28915
d. JungleJim
e. JungleJim()

11. Write statements that display on the screen
a. the character ‘x’
b. the name Jim
c. the number 509

12. True or false:
In an assignment statement, the value on the left of the equal sign is always equal to the value on the right.

13. Write a statement that displays the variable george in a field 10 characters wide.

14. What header file must you #include with your source file to use cout and cin?

15. Write a statement that gets a numerical value from the keyboard and places it in the variable temp.

16. What header file must you #include with your program to use setw?

17. Two exceptions to the rule that the compiler ignores whitespace are ________ and ________.

18. True or false: It’s perfectly all right to use variables of different data types in the same arithmetic expression.

19. The expression 11%3 evaluates to ________.

20. An arithmetic assignment operator combines the effect of what two operators?

21. Write a statement that uses an arithmetic assignment operator to increase the value of the variable temp by

23. Write the same statement without the arithmetic assignment operator.

22. The increment operator increases the value of a variable by how much?

23. Assuming var1 starts with the value 20, what will the following code fragment print out? cout << var1--; cout << ++var1;

24. In the examples we’ve seen so far, header files have been used for what purpose?

25. The actual code for library functions is contained in a ________ file.




Answers to the Questions 


1. b, c

2. parentheses

3. braces { }

4. It’s the first function executed when the program starts

5. statement

6. // this is a comment /* this is a comment */

7. a, d

8.
a. 4
b. 10
c. 4
d. 4

9. false

10.
a. integer constant
b. character constant
c. floating-point constant
d. variable name or identifier
e. function name

11.
a. cout << ‘x’;
b. cout << “Jim”;
c. cout << 509;

12. false; they’re not equal until the statement is executed

13. cout << setw(10) << george;

14. IOSTREAM

15. cin >> temp;

16. IOMANIP

17. string constants, preprocessor directives

18. true

19. 2

20. assignment (=) and arithmetic (like + and *)

21. temp += 23; temp = temp + 23;

22. 1

23. 2020

24. to provide declarations and other data for library functions, overloaded operators, and objects

25. library