XII-CS-SUMMER VACATION HOME WORK


SUMMER VACATION HOME WORK FOR XII COMPUTER SCIENCE STUDENTS 2014-15
1        1.      Differentiate between a global variable and a local variable. Also give suitable example in C++.  
  1. What is the need of defining a MACRO using #define directive. Explain with suitable   example.
3.    What is the function overloading? Explain example the term “default arguments”.          
       4.     Write the names of the header files to which the following belong:                                                         
      (i). setw()         (ii). randomized()
       5.    Name the header files, to which the following built-in functions belong
                        i) exp( )                        ii) isalnum( )
       6.    Rewrite the following program after removing the syntactical errors (if any). Underline each correction.
#include <iostream.h>
struct Pixels
{    int Color,Style;}
void ShowPoint(Pixels P)
{    cout<<P.Color,P.Style<<endl;}
void main()
{
     Pixels Point1=(5,3);
     ShowPoint(Point1);
Pixels Point2=Point1;
     Color.Point1+=2;
ShowPoint(Point2);}
         7.   Find the output of the following program:                                                                                                                                                            #include<iostream.h>
                                #include<ctype.h>
                                void main( )
                                {
                                                 char Mystring[ ] = "what@ANIDea!";
                                                                for(int I=0; Mystring [I] ! = '\0' ; I++)
                                                                {
                                                                                if(!isalpha (Mystring[I]) )
                                                                                                 Mystring[I ]= ' * ';
                                                                                else if(isupper (Mystring[I] ))
                                                                                                Mystring[I] = Mystring[I]+1;
                                                                                else
                                                                                                Mystring[I]  = Mystring[I+1];
                                                }
cout<<Mystring;     
                                     }
8.   In the following program, if the value of N given by the user is 20, what maximum and minimum values the program could possibly display?                                                                                 
void main()
{
  randomize();
  int R, Tot=0;
     
                  R=random(N) +1;
                  Tot + = R;
                  cout<< Tot;
}     
9. What are difference between constructor and destructor? Give a suitable example copy constructor. 
10. Answer the questions (i) and (ii) after going through the following program:               
class Match{
     int Time;
public:
     Match()                              //Function 1
     {
Time=0;
cout<<”Match commences”<<end1;
}
void Details()                          //Function 2
     {
cout<<”Inter Section Basketball Match”<<end1;
}

     Match(int Duration)        //Function 3
     {
Time=Duration;
cout<<”Another Match begins now”<<end1;
}
Match(Match &M)         //Function 4
     {
Time=M.Duration;
cout<<”Like Previous Match ”<<end1;
}};
i)                    Which category of constructor - Function 4 belongs to and what is the purpose of using it?
ii)                   Write statements that would call the member Functions 1 and 3
            11 . Answer the questions (i) to (iv) based on the following:                                                                                                            class CUSTOMER
{
     int Cust_no;
     char Cust_Name[20];
protected:
void Register();  
public:
     CUSTOMER();
     void Status();
};
class SALESMAN
{    int Salesman_no;
     char Salesman_Name[20];
protected:
     float Salary;
public:
     SALESMAN();
     void Enter();
     void Show();
};
class SHOP : private CUSTOMER , public SALESMAN
{
     char Voucher_No[10];
     char Sales_Date[8];
public:
     SHOP();
     void Sales_Entry();
     void Sales_Detail(); };
(i)      Write the names of data members which are accessible from objects belonging to class CUSTOMER.
(ii)    Write the names of all the member functions which are accessible from objects belonging to class SALESMAN.
(iii)   Write the names of all the members which are accessible from member functions of class SHOP.
(iv)  How many bytes will be required by an object belonging to class SHOP?

12.Write a function in C++ to return the element which is present maximum number of times in an array . the function prototype is given below.                                                                                           
Int MAX(int arr[], int size)
e.g : If the array is 2 4 2 4 2 4 2 4 2 4 2 2 4
then the function will return a vale 2
13. Name the header files that shall be needed for the following code:                   
                                        void  main()
                                        {
                                            int N, G;
                                            randomize();
                                            cin>>N;
                                  G=random(N-5)+5;
                                             cout<<G<<endl;
                                } 
14. Rewrite the following program after removing the syntax error(s), if any.  Underline      each correction                                                #include<iostream.h>
                         int main()
                                 {
                                                 struct student
                                                 {
                                                   int. rno, mark;
                                      }stu;
                                      student stuA= (1001,49);
                                              student stuB= stuA;
                                       if (stuA!= stuB)
                                                   stuA.mark= 55;
                                       else
                                                   stuB.mark= 25;
                                       cout<<stuA.mark<<stub.mark;
                          }
15.   Rewrite the following program after removing syntactical error(s) if any. Underline each correction.       
#include<iostream.h>
void main( )
{
struct movie
{ char movie_name[20];
char movie_type;
int tickets=100;
} MOVIE;
gets(movie_name);
gets(movie_type);
}
16.Differentiate between a default and a parameterized constructor in context of class and object. Give suitable example in C++. 
17.Explain with suitable examples how to create the object by calling the constructor    implicitly and explicitly.  
18. Answer the questions (i) and (ii) after going through the following class                                                         
class Computer {
char C_name[20];
char Config[100];
public:
Computer(Computer &obj);       // function1
~Computer();                                    //function 2
};
(i) Write the statement(s) which will invoke the function 1.
(ii) Name the specific feature of the class shown by function 2. Also write the time of its invoke.

19. Answer the questions (i) and (ii) after going through the following program:  
                          #include <iostream.h>
                        #include<stdio.h>
                         #include<string.h>
                         class shares { char company[20];
                             int no_of_shares;
                          public:
                          shares()                                                     / / function 1
                                   {
                              strcpy(company,”      “);
                               no_of_shares = 0;
                             }
                       
                           shares(char factory[], int n)              / / function 2     
                             {
                                 strcpy(company,factory);
                                 no_of_shares = n;
                               }
                         
                            void read_data()                             / /  function 3
                             {
                                gets(company);
                                 cin>>no_of_shares;
                               }

                              ~shares()                                                               / /  function 4
                               {
                                  cout<<”Share market holiday”<<endl;           }                     };

(i)    Write the statements to call  function 1 and  function 2.
(ii)      What is the role of function 3 and function 4 in this class shares?                    
20.Write a function in C++ which accepts an integer array and its size as arguments and change all the even number with twice and odd with thrice.                                                                                                                          
Example: if an array of five elements initially contains the element as
2,4,1,5,7
then the function should rearrange the array as
4,8,3,15,21
 21. Write a function in C++ which accepts an integer array and its size as arguments/ parameters and then assigns the elements into a two dimensional array of integers in the following format:                                                                          
If the array is 1, 2, 3, 4, 5, 6
The resultant 2 D array is given below
If the array is 1, 2, 3
The resultant 2 D array is given below
0
0
0
0
0
6
0
0
0
0
5
5
0
0
0
4
4
4
0
0
3
3
3
3
0
2
2
2
2
2
1
1
1
1
1
1
0
0
3
0
2
2
1
1
1










22.An array A[40][10] is stored in the memory along the column with each element occupying 4 bytes. Find out the Base address and address of the element A[3][6] if the element A[30][10] is stored at the address 9000.
23.Given two dimensional array A[10][20], base address of A being 100 and width of each        element is 4 bytes, find the location of A[8][15] when the array is stored as (a) column wise       (b) Row wise.           
24.An array P[20][30] is stored in the memory along the column with each of the element occupying 4 bytes, find out the memory location for the element P[5][15], if an element P[2][20] is stored at the memory location 5000.          
25.Define a class Travel in C++ with the description given below:                                                                              
Private members:
plancode of type long
place of type  characters array
number_of_travellers of type integer
number_of_buses of type integer
Public members:
A constructor to assign initial values of plancode as 1001, place as “Kolkata”, number_of_travellers as 5 and number_of_buses as 1
A function newplan( ) which allows user to enter plancode , place and number_of_travellers and also assign the number_of_buses as per the following conditions:
number_of_travellers                                  number_of_buses
less than 20                                                                        2
equal to and more than 20 and less than 40                         3
equal to and more than 40                                                   4
A function show( ) to display the contents of all the data members on the screen.

26. Define a class named DRAMA in C++ with the following description                          
Private members
SHOW_NO                                integer
NAME_OF_THE_DRAMA        Array of characters (String)
DAY                                       integer (Total number of days the same drama is shown)
DAILY_COLLECTION            float
TOTAL_COLLECTION          float
Public Members
input_data  :        A user defined function  to read an object of ENTRY type
print_data :          A function  to display the details of an object
update_data: A  function  to update the total collection and daily collection once the day
    changes.  Total collection will be incremented by daily collection and daily  collection is made Zero
 27.Define a class in C++ with following description:                                                                                                                        
Private Members
·         A data member Flight number of type integer
·         A data member Destination of type string
·         A data member Distance of type float
·         A data member Fuel of type float
·         A member function CALFUEL() to calculate the value of Fuel as per the following criteria
        Distance                                                                                                                               Fuel
        <=1000                                                                                                                                 500
        more than 1000  and <=2000                                                                                1100
        more than 2000                                                                                                             2200
Public Members
·         A function FEEDINFO() to allow user to enter values for Flight Number, Destination, Distance & call function CALFUEL() to calculate the quantity of Fuel
·         A function SHOWINFO() to allow user to view the content of all the data members

28.Answer the questions (i) to (iv) based on the following code:                                    
 
       class engineering
        {
                private:        
               char streamcode[5];
                protected:
                                int seats;
                                void allot();
            public:
                             engineering();
                          void streamread();
                           void streamwrite();
           };
          class dept : protected engineering
           {
                   char deptname[20];
                   int strength;
                public:
                                dept();
                                void deptread();
                                void deptwrite();
                };
                class course: public dept
                {
                                char coursename[20];
                                float fees;
                public:
                                course();
                                void courseread();
                                void coursewrite();};
(i)                  Which type of inheritance is shown in the above example?
(ii)                How many bytes will be required by an object of the class dept and course?
(iii)               Write the name of all the data members accessible from member functions of the class course.
(iv)              Write the members which are accessible from the object of the class dept.
29. Answer the questions (i) to (iv) based on the following code :                                                                            
class Goods
{ int id;
protected :
char name[20];
long qty;
void Incr(int n);
public :
Goods();
~Goods();
void get(); };
class Food_products : public Goods
{ char exp_dt[10];
protected :
int id;
int qty;
public :
void getd();
void showd(); };
class Cosmetics : private Goods
{ int qty;
char exp_date[10];
protected :
int id;
public :
~Cosmetics();
Cosmetics();
void show();
};
(i) How many bytes will be required by an object of class  Food_products.
(ii) Name the member functions accessible through the object of class Food_products.
(iii) From the following, Identify the member function(s) that cannot be called directly from the object of class Cosmetics
show(), getd(), get()
(iv) If the class cosmetics inherits the properties of food_products class also, then name the type of inheritance.

******************************************************************

Popular posts from this blog

XII- CS-- SOLVED SQL queries (SQL PRACTICAL ASSIGNMENS)

SQL--HOME ASSIGNMENTS(XII Class)

Python-MySQL Connectivity