HOLIDAY HOME WORK FOR CLASS XII B 2016-17 (SUMMER VACATION)
Q1. Observe the following C++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C++ compiler :
void main()
{
char CH,STR[20];
cin>>STR;
CH=toupper(STR[0]);
cout<<STR<<”starts with”<<CH<<endl;
}
Q2. Rewrite the following C++ code after removing all the syntax error(s), if present in the code. Make sure that you underline each correction done by you in the code.
Important Note:
– Assume that all the required header files are already included, which are essential to run this code.
– The corrections made by you do not change the logic of the program.
typedef char[80] STR;
void main()
{ Txt STR;
gets(Txt);
cout<<Txt[0]<<’\t<<Txt[2];
cout<<Txt<<endline;
}
Q3. Deepa has just started working as a programmer in STAR SOFTWARE company. In the company she has got her first assignment to be done using a C++ function to find the smallest number out of a given set of numbers stored in a one-dimensional array. But she has committed some logical mistakes while writing the code and is not getting the desired result. Rewrite the correct code underlining the corrections done. Do not add any additional statements in the corrected code.
int find(int a[],int n)
{ int s=a[0];
for(int x=1;x<n;x++)
if(a[x]>s)
a[x]=s;
return(s);
}
Q4. Find output of the following program segment:
#include<iostream.h>
#include<ctype.h>
void Mycode(char Msg[],char CH)
{
for(int cnt=0;Msg[cnt]! =‘ \ 0’ ;cnt++)
{
if(Msg[cnt]>=‘B’&& Msg[cnt]<=‘G’)
if(Msg[cnt]>=‘B’&& Msg[cnt]<=‘G’)
Msg[cnt]=tolower(Msg[cnt]);
else
if(Msg[cnt]==‘N’Msg[cnt]==‘n’Msg[cnt]==‘’)
Msg[cnt]=CH;
else
if(cnt%2==0)
Msg[cnt]=toupper(Msg[cnt]);
else
Msg[cnt]=Msg[cnt–1];
}
}
}
void main()
{
char MyText[]="Input Raw";
char MyText[]="Input Raw";
Mycode(MyText, ‘ @’);
cout<<"NEW TEXT:"<<MyText<<endl;
}
}
Q5. Write a user defined function DIVT() which takes an integer as parameter and returns whether it is divisible by 13 or not. The function should return 1 if it is divisible by 13, otherwise it should return 0.
Q6. Rewrite the following program after removing the syntactical error(s), if any. Underline each correction.
#include <iostream.h>
void main()
{
struct STUDENT
struct STUDENT
{
char stu_name [20];
char stu_name [20];
char stu_sex;
int stu_age=17;
} student;
gets(stu_name);
gets(stu_sex);
}
}
Q7. What are Nested Structures? Give an example.
Q8. Find the output of the following program:
#include<iostream.h>
void main( ) { long NUM = 1234543;
int F = 0, S = 0;
do
{ int Rem = NUM% 10;
if (Rem % 2 !=0)
F+ =R;
else
S+ = R;
NUM/=10;
} while(NUM>0);
cout<<F-S;
}
Q9. Study the following C++ program and select the possible output(s) from it : Find the maximum and minimum value of L.
#include<stdlib.h>
#include<iostream.h>
#include<string.h>
void main()
{randomize();
char P[]="C++PROGRAM";
long L;
for(int I=0;P[I]!='R';I++)
{ L=random (sizeof(L)) +5;
cout<<P[L]<<"-";
} } }
i) R-P-O-Rii) P-O-R-+-iii) O-R-A-Giv) A-G-R-M
Q10. Write a program to find out volume of the following using function overloading.
i). volume of cube
ii). volume of cuboid
iii). volume of cylinder
Q11. Write a program to find area of following using function overloading.
i). Area of circle (function with one parameter)
ii). Area of rectangle (function with two parameters)
iii). Area of triangle (function with three parameters)
Q12. Fill in the blanks:
i). Act of representing essential features without background detail is called ___________.
i). Act of representing essential features without background detail is called ___________.
ii). Wrapping up of data and associated functions into a single unit is called_________.
iii). ____________is called the instance of a class.
Q13. Define a class Tourist in C++ with the following specification:
Data Members - private
● CNo - to store Cab No
● CType - to store a character ‘A’, ‘B’, or ‘C’ as City Type
● PerKM - to store per Kilo Meter charges
● Distance - to store Distance travelled (in KM)
Member Functions - public
● A function CityCharges( ) to assign PerKM as per the following table :
CType
|
PerKM
|
A
|
20
|
B
|
18
|
C
|
15
|
● A function RegisterCab() to allow administrator to enter the values for CNo and CType. Also, this function should call CityCharges() to assign PerKM Charges.
● A function Display() to allow user to show the values of Distance and display CNo, CType, PerKM, PerKM*Distance (as Amount) on screen.
Q14. Define a class REPORT with the following specification
private:
Adno - 4 digit admission number
Name - 20 characters
Marks - an array of floating point values
Averge - average marks obtained
Getavg( ) - to compute the average obtained in five subjects
public:
Readinfo( ) - function to accept values for adno, name, marks and
Invoke the function Getavg( )
Displayinfo( ) - function to display all data members on the screen.
Q15. What is Object Oriented Programming? List some of its advantages
Q16. Explain Data Hiding with respect to OOP.
Q17. Differentiate between an object and a class.
Q18. Consider the figure given below and answer the questions that follow:
a. Name the base class and the derived class.
b. Which concept of OOP is implemented in the figure given above?
Q19. Write the names of the header flies to which the following belong:
(i) sqrt() (ii) isalpha() (iii) puts() (iv) strcpy() (v) setw() (vi) abs() (vii) isupper() (viii) strcat() (ix) random() (x)getchar()
_________________________________________________________________________
NOTE: HOLIDAY HOME WORK FOR CLASS XII B 2016-17.