CPP QN 2019
CPP QN 2019
Semester :I
3.
3 Attempt any four questions from Section B.
SECTION A
float f;
int *b &f
P.T.O.
8591
zl = Y+t
cout<<zl<< \n"<<y
else
z1 y+x/2;
cout<<z1<<y;
(2)
(i) int x 4, Y = 3;
(2)
iv) int i
int b[]={101, 120, 130,-340, -112,
-114};
for
for (i = 0: b[i]>0; i++)
(v) int i =
890
double x = 4.678
cout<<setw ( 5) <<i<<"\n" ;
cout<fixed;
cout<<setprecision (6)
cout <"x="<<x<<" \n";
cout<<oct<<"Octal="<<i; (4)
of C plus plus");
int j
int k = 0;
int count=0
S.find ( 'u' , k);
P.T.O.
8591 4
while (j!=-1)
Count++;
j s.find( "u',j+1);
Cout<<count; (4)
(vii) class Base
publiC:
Base ()
public:
Derived1 ()
cout<<"Inside Derivedl\n";
8591
class Derived2 public Derived1
publiC
Derived2 ()
Base o1
Derivedl o2
Derived2 o3;
(3)
int a
*p a
a *at1
return ai
(3)
P.T.O.
8591 6
(i) void try(int a,int b)
(1)
(d) Write a function to remove duplicate element from
one dimensional integer array A of size n. (5)
int x =
0
while (x<10)
cout <x<<endl;
x++
(3)
SECTION B
)t I z <(y+5) && Y
ii) 3*y/4856&y
execution of
What will be the output produced on
3. (a)
the following code segment:
#include<iostream>
void main()
int i
int j = 11;
int m 6
i 1;i<=m i++)
for (int =
P.T.O.
8591 8
{
for (int t 1; t<=j; t++)
cout<<t;
j j-2
cout<" \n";
(5)
class Rationalnumber
int P,q
#include<iostream>
using namespace std;
void main ()
P.T.O
8591 10
class X
int il;
publicc:
x()
il =
15
cout<<"il="<<il<<endl;
class Y public X
int j1
8591 11
public
Y()
j1 10;
class Z:public Y
int k1;
publiC:
k1 20;
P.T.O.
8591 12
Write code fragments for the following:
#include<iostream>
using namespace std;
class myexception
string str;
public
myexception (string p)
str=p;
void display ()
cout <str;
8591
13
void main ()
int n, m;
try
5;
-6
if (n<0)
throw myexception ( "Negative
number") ;
cout<<n<<endl;
if (m0)
o1.display ();
(5)
P.T.O.
8591 14
7.
1. (a) Identify in the
an error
following code and give
reasons for the same
) #include <iostream>
using namespace std;
class US1
int P
protected:
int q
public
int ;
protected:
float S,u;
void main()
US1 o1;
US2 02;
cout<<ol.p;
anmmYAE
15
8591
cout<<ol.qi
cout<Kol.r;
cout<<o2.p;
cout<<o2.q;
cout<<o2.r;
cout<<o2.s;
cout<<o2.u;
(3)
(ii) do
int ctr=0;
cout<<ctr;
ctrt+
if (n==0) return 1
(1)
(b) Write C++ declarations for the
following:
(2+2)
P.T.O.
8591 16
(1300)