- What is encapsulation in OOP? Give an example
- What is the time complexity of fun(). Please show your proof.
int fun(int n)
{
int count = 0;
for (int i = n; i > 0; i /= 2) for (int j = 0; j < i; j++) count += 1; return count;
}
- Give a concise formula that gives the approximate number of digits in a positive integer. The integer is written in base 10.
- What are the differences between references and pointers?
- What are the three ways we can use items defined in a namespace. Include examples in your answer.
- Discuss about the output of the following code. How the result will change if we replace struct with class?
| 1. struct Test { |
| 2. int x; |
| 3. }; 4. |
| 5. int main() { |
| 6. Test t; |
| 7. t.x = 20;8. cout<t.x<endl;9. return 0; |
| 10. } |
- A The header of the point class is as follows:
| 1. class point2. { | |
| 3. public:4. // CONSTRUCTOR | |
| 5. point (double initial_x = 0.0, double initial_y = 0.0); 6.7. // MODIFICATION MEMBER FUNCTIONS8. void set_x (double& value);9. void set_y (double& value);10. | |
| 11. // CONST MEMBER FUNCTIONS12. point operator+ (double& in) const;13. | |
| 14. private:15. double x; // x coordinate of this point16. double y; // y coordinate of this point | |
| 17. | |
| 18. }; | |
- Which line of the following code results in an error? Explain why. Whats the solution?
- What is the output of this code? Discuss your answer.

![[Solved] COEN79-Homework 2](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] COEN79-Lab 7](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.