cpp2024pyq
cpp2024pyq
Semester : II
P.T.0.
2
4076
Section A
(Compulsory Question)
following: (3)
Write a code snippet to do the
1. (a)
initialized
to char and
" Declare str, a pointer
aue to the value NITIN".
k
(ii) for (int j=l;j<=4 2
2 ;j++)
for (int k=l;k<=j; k=k+2) 2
46 cout<< (j+k) ;
cout<<endl:
3
4076 3
switch(A(k})
case 'R': cout<<"It is red color";
break;
case 'G': cout<<"It is green color";
break;
case 'Y': cout<<"It 1s yellow color";
break;
default: cout<<"No color":
cout<<"Inside Frt"<<endl; H
this->>X=%;
this->y=yi
cout<<this->x<<this->y<<endl;
}
void main()
P.T.O.
4 4076
4076
m)
fl(int& I, int&
(v) void
I-I+10;
m=m+15;
int main ()
} cout<<"Caught"<<i<<endl; clas
publ
virtu
int main() {
Cout
try
{ };
4076 5
exc1 (4) ;
excl (5) ;
catch (...)
cout<<"all caught":
return 0;
public:
virtual void show()
{
cout<<"Inside base B1";
Alun) P.T.0.
x
4076
Derived:
6
public Base
optcam fout(Ca 2.tx 4(
class
public:
void show ()
cout<<"Inside d e r i v e d " :
3
void main ()
-i moondett
(e) Write a program to copy the content of the file
*Al.txt" to another file A2.txt", word by word.
Also, display the number of words copied.
3.
(3)
Section B {
it;
coutKecotKKaál;
debits
void withdraw (double x): This function
(11)
only if the
(subtracts) x from the balance
"unable to
(balance-x) >=500 else the message,
debit, the minimum balance should
be 500" is
printed.
protected:
double area;
public :
Figure ()
4076
cout<<" Figure Constructor":
area-0:
double radíus;
publíc:
circle (double r)
voíd display ()
area-3.14*radiug*radius;
ig"<<areaxkendl;
cout<<"The area of círcle
void display ()
area=length*breadth;
cout<<"The area of rectangle is"<<area<<endl;
int main ()
circle cl(4.5) ;
rectangle rl(5, 6) ;
cl.display () i 6395
rl.display () i
return 0;
30.
P.T.0.
4076 10
int a(20);
int n; clas (R)
T aJ ;
AeH (3)
Rewrite the above class using templates suitably.
Also, define the following member functions in
the class :
int pi
protected:
char s;
public
float qi
first c(int pl, char s1, float ql) :p(p1), s(sl),
q(q1)}
void nain ()
first_c tl(
cout<<tl.p; l o
cout<<ti.s: leu
cout<<tl.q:
ottd
secondc t2(1,3.4£, 'y',56.7):
cout<<t2.pi |) Prt ein
cout<<t2.si
cout<<t2.qi
cout<<t2.tl: |/ tl ret
(b) Consider the following
function declaration:
void sort (int al],int
n)
4076 12