Docsity

Homework 1 - Software and Object-Oriented Programming - Fall 2004 | ECS 040, Assignments of Computer Science

Toggle sidebar
bg1
Homework 1 - ECS 40 Summer Session I 2004
Due Date: Tuesday, June 29, 2:00 pm (In Class)
(No Late submissions will be accepted)
35 points
1 Matching
For each term, write the corresponding letter for the description that best matches it.
1. Hardware
2. Stream extraction operator
3. ALU
4. Portable
5. Computer
6. Objects
7. Stream insertion operator
8. Structured programming
9. CPU
10. High-level language
a) Device capable of performing computations and making logical decisions at speeds millions and even billions
of times faster than a human being.
b) ”Administrative” section of a computer.
c) Programming language, like C and C++, in which simple statements accomplish substantial tasks.
d) Devices such as the screen, keyboard, CD-ROM, memory and processing unit.
e) Disciplined approach to writing programs that are clear, easy to test and debug, and easy to modify.
f) Reusable software components.
g) Property of carefully designed programs which allows them to run on different computers.
h) >>.
i) ”Manufacturing” section of a computer. Performs calculations.
j) <<.
2 Fill in the blanks
1. Single-line comments begin with .
2. The and statements are used with control struc-
tures to alter the flow of control.
3. To specify that a function does not return a value, keyword is used.
4. To use function sqrt, the header file must be included.
5. All strings end with the character.
6. Arrays are passed to functions call-by .
7. Pointers are variables that contain other variables’ .
8. The * operator is referred to as the , or operator.
9. private member functions are visible only to of the same class.
10. When a member function is defined outside of the class definition, the function name is preceded by the
name and the operator.
1
pf3

Partial preview of the text

Download Homework 1 - Software and Object-Oriented Programming - Fall 2004 | ECS 040 and more Assignments Computer Science in PDF only on Docsity!

Homework 1 - ECS 40 Summer Session I 2004

Due Date: Tuesday, June 29, 2:00 pm (In Class)

(No Late submissions will be accepted)

35 points

1 Matching

For each term, write the corresponding letter for the description that best matches it.

  1. Hardware
  2. Stream extraction operator
  3. ALU
  4. Portable
  5. Computer
  6. Objects
  7. Stream insertion operator
  8. Structured programming
  9. CPU
  10. High-level language

a) Device capable of performing computations and making logical decisions at speeds millions and even billions of times faster than a human being. b) ”Administrative” section of a computer. c) Programming language, like C and C++, in which simple statements accomplish substantial tasks. d) Devices such as the screen, keyboard, CD-ROM, memory and processing unit. e) Disciplined approach to writing programs that are clear, easy to test and debug, and easy to modify. f) Reusable software components. g) Property of carefully designed programs which allows them to run on different computers. h) >>. i) ”Manufacturing” section of a computer. Performs calculations. j) <<.

2 Fill in the blanks

  1. Single-line comments begin with.
  2. The and statements are used with control struc- tures to alter the flow of control.
  3. To specify that a function does not return a value, keyword is used.
  4. To use function sqrt, the header file must be included.
  5. All strings end with the character.
  6. Arrays are passed to functions call-by.
  7. Pointers are variables that contain other variables’.
  8. The * operator is referred to as the , or operator.
  9. private member functions are visible only to of the same class.
  10. When a member function is defined outside of the class definition, the function name is preceded by the name and the operator.

3 Code

Please read the code snippet below answer the questions that follow. The code compiles correctly.

// -----File A.h begins here----------- 1 #ifndef A_H 2 #define A_H 3 4 #include 5 6 7 class A { 8 9 public: 10 A (int x); 11 void print() const; 12 void increment(const int); 13 14 private: 15 int val; 16 17 }; 18 19 #endif 20 // ------File A.cpp begins here 21 #include "A.h" 22 23 A :: A(int x) 24 { 25 val = x; 26 27 } 28 29 void A :: print (void ) const 30 { 31 cout << "Value of val is: " << val << endl; 32 } 33 34 void A :: increment(const int i) 35 { 36 val*=i; 37 38 } 39 //-----File main.cpp begins here 40 #include "A.h" 41 42 void test (A&); 43 44 int main() 45 { 46 A a(60); 47 48 A * aPtr = & a; 49 50 a.print(); 51 test(a);