



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Answer: d. It's recursive multiplication and test(a+test(a,b-1)) iteratively calculates b times sum of a. Page 6. STEM Success Center. CS 211. Worksheet. 5 ...
Typology: Slides
1 / 7
This page cannot be seen from the preview
Don't miss anything!
CS 211 Data Structures using C++
CS 211
CS 211 Solutions
1. What will be the output of the below program? class Num{ int a; }; void main() { Num n; cout << n.a; } a) Compile error b) n.a c) n d) Garbage value Answer: a Since the default access is private in c++, a is a private member of Num and so it causes a compiler error to access it outside the class. 2. Create a class named ‘Employee’ with an integer variable ‘Employee_ID’ and a string variable ‘Employee_name’. Create an object of the class employee and assign values to Employee_ID and Employee_name. Answer: class Employee { public: int Employee_ID; string Employe_name; }; int main()
CS 211
Employee e; e.Employee_ID=43; e.Employee_name=”Jey”; cout<< e.Employee_ID << e.Employee_name<<endl; return 0; }
3. Which of the following is used to define the class member externally? a. : b. ; c. # d. :: Answer: d :: is used to define members of the class globally. 4. What is the value of the test(12,13)? int test(int a, int b) { if (a == 0) return 0; return test(a+test(a,b-1)); } a. 1 b. 26 c. 0 d. 156 Answer: d It’s recursive multiplication and test(a+test(a,b-1)) iteratively calculates b times sum of a.
CS 211
6. What will be the output of the following program? #include