CBSE Guess > Papers > Important Questions > Class XII > 2012 > Computer Science > Computer Science Mr. Pradumna Singh Computer Science- CBSE CLASS XII Q1. What is the difference between call by reference & call by value method in a user defined function in C++? Explain it with suitable example. For - 2 Marks Ans. Call by value : In this method, actual arguments of a calling function gets duplicated as formal arguments & are made available to the called function. As a result whatever change is made by called function in these arguments, are not reflected back in actual arguments. In the function’s argument we simply specify ‘&’ operator along with the argument(s) which are being called by reference. Q.2.Write the names of the header files, which is/are essentially required to execute the following functions: For - 1 Marks i) isdigit( ) ii) sin( ) Ans. i) ctype.h ii) math.h Q .3 . Rewrite the following program after removing all the syntactical errors (if any), underlining each correction. : For - 2 Marks include<iostream.h> Ans. #include<iostream.h> Q 4. Give the output of the following program ( Assuming that all required header files are included in the program ) : For - 2 Marks #define i 5 Ans. 30$10 Q . 5. Give the output of the following program ( Assuming that all required header files are included in the program ) : For - 2 Marks Q. 6.Go through the following c++ code, find out the correct possible output(s) from the suggested output options i) to iv). Also write the highest value which can be assigned to variable G : For - 2 Marks
Ans. Options ii) & iv) will be the correct possible outputs. The highest value of variable G would be 34 Q. 7. What is constructor overloading? Support your answer with example. For - 2 Marks Ans. CONSTRUCTOR OVERLOADING : When more than one constructor appears inside a single class, it is said to be constructor overloading i.e. if we have two or more constructors inside a class, it is said to be an overloaded constructor. For ex. Here in the above written example, we see three constructors one after another. Since all of them share the same class name and are different in their type and number of arguments, therefore supports overloading mechanism of OOP. Q. 8 . Answer the questions (i) and (ii) after going through the following class : For - 2 Marks
BUS(char * name, char *tno, float N) { strcpy(Pname,name); strcpy(TicktNo,tno); Fare=N; }
{ strcpy(Pname,F.Pname); Prepared By: Mr. Pradumna Singh |