Programming in C++ Lesson Plan Subject code: 10EC761 No.of hours: 52 Faculty: Lakshmi Naga Prasanna.R Exam Marks:100 Class No. Topic to be covered Chapter Title Part A 1 Getting started, the C++ program, Preprocessor Directives. 2 The Built-In Array Data Type. Unit 1 C++, AN OVERVIEW 3 Dynamic Memory Allocation and Pointers 4 An Object based Design, An Object-Oriented Design, 5 An Exception based Design. 6 An array. 7 Literal Constant, Variables. Unit 2 8 Pointer Types THE BASIC LANGUAGE: 9 String Types 10 Const Qualifier, Reference Types 11 The Bool Type, Enumeration types 12 Array Types. The vector Container Type. 13 Arithmetic Operators Unit 3 14, 15 Equality, Relational and Logical Operators, OPERATORS 16 Assignment Operators 17, 18 Increment and Decrement operator, The Conditional Operator, 19 Bitwise Operator, Bitset Operations 20 Statements: if, switch 21, 22 for Loop, while, break, goto, continue Statements. 23 Prototype Unit 4 24, 25 Argument passing, FUNCTIONS. 26 Recursion and linear (or inline) function. Part B 1
27, 28 Throwing an Exception, Unit 5 EXCEPTION HANDLING 29, 30 Catching an Exception 31 Exception Specifications 32 Exceptions and Design Issues. 33 Definition Unit 6 CLASSES 34 Class Objects 35 Class Initialization 36, 37 Class Constructor, The Class Destructor 38, 39 Class Object Arrays and Vectors. 40, 41 Overload Operators Unit 7 42, 43 Operators ++ and --, 44, 45 Operators new and delete. 46-48 Multiple Inheritances, Unit 8 49, 50 public, private & protected inheritance, 51, 52 Class scope under Inheritance. TEXT BOOK: T1. C++ Primer, S. B. Lippman & J. Lajoie, 3rd Edition, Addison Wesley, 2000. REFERENCE BOOKS: R1. C++ Program Design: An Introduction to Programming and Object- Oriented Design. Cohoon and Davidson, 3rd Edn. TMH publication. 2004. R2. Object Oriented Programming using C++, R. Lafore, Galgotia Publications, 2004. R3. Schaum s outlines, Programming with C++, J. R. Hubbard, Ph. D., 2 nd Edition, Tata McGraw-Hill, 2002. Assignments: Serial no. Question type To be submitted on * 1. Question Bank Unit 1, 2 and a part of 3. 2 weeks before T1. 2. Question Bank Unit 3, 4, 5 and a part of 6. 2 weeks before T2. 3. Question Bank Unit 6, 7. and 8 2 weeks before T3. Internal Test Portions: Test I : Unit 1, 2 and a part of 3. Test II: Unit 3-5, and a part of 6. Test III: Unit 6 8. 2
Question Bank Unit 1. C++, AN OVERVIEW 1. What are the advantages of object oriented languages over procedure oriented languages? 6M 2. List a few areas of application of OOP technology. 6M 3. What is enumerated data type?explain. 6M 4.What are preprocessor directives?what is their function? Give six examples of preprocessor directives. 5. With an example, explain the data types and variables in C++. **06M 6. Write a program to find the roots of a quadratic equation ax2+bx+c=0 using switch and CASE.7M 7.Write a single C++ statement that subtracts the sum of x and y from z and then increment y. 03 M 8.What is the difference b/w reserved word and a standard identifier? 3M 9.Write a single C++ statement that prints Too many if the variable count exceeds 100.. 03 marks 10.Describe the two ways to include comments in a C++ program. 03M 11. What will be the values of m and n in each of the following instruction execution: (i) m *= n++; (ii) m += --n; m=5 and n=2 before instruction execution. 06 marks 12. Evaluate each of the following expressions, assuming in each case that m has the value 25 and n has the value 7. (i) m%n (ii) m%n++ (iii) m%==n (iv) ++m n-- 06 marks 13.Explain the difference between the four objects defined below. (v) int ival=1024; (vi) int *pt2 = new int(1024); (vii) int *p1 = &ival; (viii) int *pi3 = new int[1024]; 06 marks Unit 2. The Basic Language 1. Give 1 example each for objects, lvalues, mutable lvalues and immutable lvalues. 06 marks 2. Give 5 examples of C++ keywords. 05 marks 3. What are the restrictions for variable names? Give one example of an illegal variable 02+01+01 marks name. The following variables india and India are different variable names. True/False? 4. Write a program to traverse an array with a pointer.. 06 marks 5.Write a c++ program to find the prime numbers between 200 and 500 using for loop. 6.What are manipulators.explain the usage of same with an example. 6M 6M Unit 3. Operators 1. Explain the various looping constructs available in C++ with their syntax. **07 marks 2. Write a C++ program to input a series of integer numbers and sum them and **08 marks terminate when the number is zero. i) using for loop ii) using while loop. 3. Write a C++ program to add the first 15 even numbers and display their sum. **05 marks 4. Explain the difference between the following three declarations: int n1=n; int& n2=n; p=&n 02 marks 5. Name the operators which are common for c and c++.indicate its precedence and associativity.also mention the operators which are exclusive for c++. 8M 6. What are bitwise operators?explain the left shift and right shift operations with examples. 5M Unit 4. Functions 1. Write a program to compute the factorial of consecutive integers using 10 marks 3
recursive function. 2. What is the utility of writing functions instead of writing a single main 10 Marks program? 3. With the help of an example explain the utility of Inline Function? 05 marks 4. Describe the various types of operators available in C++ with example. **06 marks 5. How do you pass an array to a function? Explain with example program. **08 marks 6. Write a C++ program to calculate area and perimeters of a circle. **06 marks 7. Write a c++ program to swap two numbers using call by address explain the mechanism. 10M Unit 5. Exception Handling 1. What is exception handling? With an example, briefly explain try, throw and **10 marks catch mechanisms in C++. 2. Explain what happens during stack unwinding. 05 marks 3. Give two reasons that the exception declaration of a catch clause should 06 marks declare a reference. 4. Explain with the help of a program the concept of Rethrow. 06 marks 5. Write a c++ program to illustrate the process of catching all uncaught exceptions through in a try block. 10M Unit 6. CLASSES 1. Implement a Point class for three-dimensional points (x,y,z). Include a default constructor, a copy constructor, a negate() function to tra nsform the point into its negative, a norm() function to return the point s distance from the origin (0, 0, 0) and a print() function. 10 marks 2. How many times is the copy constructor called in the following code: 10 marks Widget f(widget u) {Widget v(u); Widget w=v; return w; } main() {Widget x; Widget y=f(f(x)); } 3. Define class and object. With the help of general syntax describe a class, class **10 marks members and class object arrays and vectors. 4. What are class constructor and class destructor? Give the characteristics of each **10 marks (through example program) to find the length of a string. 5. Explain different types of constructors,with example. 10M 6. Write short note on friend functions and explain with an example. 8M 7. Explain OOPS features. 10M Unit 7. 1. How the operator keyword is used? Give two examples. 04 marks 2. Implement the binary subtractor operator, the unary negation operator, and the less 10 marks than operator < for the Ratio class: class Ratio { friend Ratio operator*(const Ratio&, const Ratio&); public: Ratio(int =0, int =1); Ratio(const Ratio&); Ratio& operator=(const Ratio&); //other declarations go here private: 4
int num, den; //other declarations go here }; 3. What is operator overloading? With the general syntax explain the process of **10 marks operator overloading. 4. Write a C++ program to overload the + + and - - operator. **10 marks Unit 8. 1. What is the difference between protected and private members? 03 marks 2. What is inheritance? Briefly explain public, private and protected inheritance, **10 marks with an example. 3. What is multiple inheritance? Explain with one C++ program. **10 marks 4. Write a note on base class and derived class. 4M 5. Explain this pointer with an example 5M 6. Explain virtual functions with an example program. 8M 5