class-xii-computer-sc-ut-1-2018-19
class-xii-computer-sc-ut-1-2018-19
CLASS-XII
SUB:- COMP.SC.
MM:-40 Time:- 90 Min
Instructions:-
(1) All questions are compulsory.
(2) Programming Language:- C++
Q 1. (a) What is the difference between local variable and global variable? Also give a suitable C++ code to illustrate both. 2
(b) Name the header file to be included for the use of following built in – functions (any two)
(a) rand() (b) toupper()
(c) pow() (d) exit() 2
#include <iostream.h>
#include <stdlib.h>
void main()
{
int N,Guessnum;
randomize();
cin>>N;
Guessnum=random(N-10)+10;
cout<<Guessnum<<endl;
}
Student(student S) // Function 3
{ rollno= S.rollno;
Strcpy(name, S.name) ; }
(d) Answer the questions (i) to (v) based on the following code : 4
class Employee
{ int id;
protected:
char name[20];
char doj[20];
public :
Employee( ); ~Employee( );
void get( ); void show( );
};
class Daily_wager : protected Employee
{ Int wphour;
protected :
int nofhworked;
public :
void getd( );
void showd( );
};
class Payment : private Daily_wager
{ char date[10];
protected :
int amount;
public :
Payment( );
~Payment( );
void show( ); };
(i) Name the member functions, which are accessible by the objects of class Payment.
(ii) From the following, Identify the member function(s) that can be called directly from the object of class Daily_wager
class show( ), getd( ), get( )
(iii) Find the memory size of object of class Daily_wager.
(iv) What type of inheritance is there in this program.
(e) What do you understand about a member function? How does a member function differ from an ordinary function? 2
(f) Differentiate Private & Public visibility mode. 2
(g) How does a class enforce data-hiding, abstraction and encapsulation? 3