August 2010 Master of Computer Application (MCA) ± Semester 2 MC0066 ± OOPS using C++ ± 4 Credits

(Book ID: B0681 & B0715)

Assignment Set ± 1 (40 Marks)
Answer all Questions Each Question carries FIVE Marks

Book ID: B0681 1. Describe the steps in compiling and executing a C++ program with programmatic illustration. Answer. There are three steps in executing a c++ program: Compiling, Linking and Running the program. The c++ programs have to be typed in a compiler. All the programs discussed in the book will be compiled on turbo c++ compiler. The turbo c++ compiler comes with an editor to type and edit c++ program. After typing the program the file is saved with an extension .cpp. This is known as source code. The source code has to be converted to an object code which is understandable by the machine. This process is known as compiling the program. You can compile your program by selecting compile from compile menu or press Alt+f9. After compiling a file with the same name as source code file but with extension .obj. is created. Second step is linking the program which creates an executable file .exe (filename same as source code) after linking the object code and the library files (cs.lib) required for the program. In a simple program, linking process may involve one object file and one library file. However in a project, there may be several smaller programs. The object codes of these programs and the library files are linked to create a single executable file. Third and the last step is running the executable file where the statements in the program will be executed one by one. When you execute the program, the compiler displays the output of the program and comes back to the program editor. To view the output and wait for user to press any key to return to the editor, type getch() as the last statement in the program. Getch() is an inbuilt predefined library function which inputs a character from the user through standard input. However you should include another header file named conio.h to use this function. Conio.h contains the necessary declarations for using this function. The include statement will be similar to iostream.h.

Press F8 to execute the next statement till you reach the end of the program. using variables without declaration etc. Syntax error This error occurs due to mistake in writing the syntax of a c++ statement or wrong use of reserved words. However it can be traced using the debug tool in the editor. Then Run the program by selecting Ctrl + f9 or Run option from run menu. improper variable names. if there are any errors that will be listing by the compiler. You can see the statement and make correction to the program file. A red line will appear on the statement. 2. Linker error This error occur when the files during linking are missing or mispelt 4. Examples are : missing semi colon or paranthesis. In this way you can watch closely the values in the watch variables after execution of each and every statement in the program. This will not be identified by the compiler. Write the variable name in the watch expression. The watch variables and their values at that point of time will be displayed in the bottom in the watch window. save and recompile it. Then select Debug ->Toggle Breakpoint (or press ctrl + f8). First identify the variable which you suspect creating the error and add them to watch list by selecting Debug ->Watches->Add watch.Compiling and Linking During compilation. If you want to exit before execution of the last statement press Ctrl + Break. To remove the breakpoint in the program go to the statement where you have added breakpoint select Debug ->Toggle Breakpoint (or press ctrl + f8). You can compare the expected value with the actual value to identify the error. Select Debug -> watch ->remove watches to remove the variables in the watch list. After adding all the variables required to the watch list. Runtime error This error occurs if the program encounters division by zero. go to the statement from where you want to observe. 3. If you are not sure. The errors may be any one of the following 1. The execution will halt at the statement where you had added the breakpoint. Appropriate error message and the statement number will be displayed. accessing a null pointer etc during execution of the program . type integer for int datatype etc. you can go to the first statement of the program. This tool helps in knowing the values taken by the variable at each and every step. Logical error This error occurs due to the flaw in the logic.

2.j)) = A(i. Book ID: B0715 5. Illustrate with suitable examples various file handling methods in C++. Describe the theory of Derivation and Inheritance. 8. R rows and C columns we define a Saddle-Point as Saddle_Pt (A(i. Given a RxC Matrix. Describe the theory with programming examples the selection control statements in C++. 6. 4. Explain the concept of class templates in C++ with some real time programming examples.7 is Saddle_Pt. i. 123 456 789 -. 7. Describe the Friend functions and friend classes with programming examples. Describe and Demonstrate the concept of Pass by Value and Pass By Reference using appropriate programming examples of your own.e. e. August 2010 Master of Computer Application (MCA) ± Semester 2 .1) Write a program in C++ to check and print for saddle points in a matrix. 3.j) is the minimum of Row i and the maximum of Col j. A.g. at position (3.

Describe the theory behind Virtual Functions and Polymorphism along with suitable programming examples for each. 6. Write about the following with respect to: A) Instance Diagrams B) Sequence Diagrams C) Collaboration Diagrams . Explain Class templates and function templates.MC0066 ± OOPS using C++ ± 4 Credits (Book ID: B0681 & B0715) Assignment Set ± 2 (40 Marks) Answer all Questions Each Question carries FIVE Marks Book ID: B0681 1. Write a program in C++ for copying and printing the contents of files. Explain the theory and applications of Sequence containers. Discuss the theory of Exception specifications with suitable code snippets for each. Explain the concept of constructors and destructors with suitable examples. 2. 7. Book ID: B0715 5. Describe the following: a) Types of Inheritance b) Objects and Pointers 3. 8. 4.

Sign up to vote on this title
UsefulNot useful