0% found this document useful (0 votes)
46 views3 pages

P18 - C++

c++

Uploaded by

Rohit Kshirsagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views3 pages

P18 - C++

c++

Uploaded by

Rohit Kshirsagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

P18 C++

21 #include<iostream.h>
void main()
{
do
{
int b=0;
cout<<b;
b++;
}hile(b!=10);
}
"here is nothin# ron# in the $ro#ram.
%ariable &b' must not be initiali(ed in the loo$
%ariable &b' must not be declared in the loo$
"he condition )or hile loo$ is not valid
22 *ach #eneric t+$e in a tem$late )unction de)inition is
$receded b+ the ,e+ord-----.
class
t+$e
)unction
tem$late
2. #include<iostream.h>
void main()
{
int a/01 = {100222.2222300};
int b/01;
b=a;
)or(int i=0;i<0;i++)
cout<<b/i1<<endl;
}
100222.2222300
#arba#e values
error
4one
23 5hat is the out$ut o) the )olloin# code6
#include<iostream.h>
void main()
{
int a/01 = {1222.};
)or(int i=0;i<0;i++)
cout<<a/i1<<endl;
}
4o out$ut
1 2 . #arba#e #arba#e
1 2 . 0 0
"here is a run time error
20 #include<iostream.h>
int a = 1;
void main()
{
int a = 100;
{
int a = 200;
{
int a = .00;
cout<<a<<727;
}
cout<<a<<727;
}
cout<<a<<727;
cout<<88a<<727;
}
*rror
1002 2002 .002 1002
.002 2002 1002 #arba#e2
.002 2002 1002 12
29 #include<iostream.h>
void main()
{
int :=10;
(:<0)6(int a =100)8(int a =1000);
cout<<a;
}
*rror
1000
100
4one
2; #include<iostream.h>
void main()
{
int :=0;
hile(:++<0)
{
static :;
:+=2;
cout<<:<<7 7;
}
}
1 2 . 3 0
2 3 9 < 10
=om$ile "ime error
>untime *rror
2< #include<iostream.h>
void main()
{
int arr/21/.1/21={{{223}2{;2<}2{.23}2}2 {{222}2{22.}2
{.23}2 }};
cout<<(?(?(?arr+1)+2)+0)+;;
}
10
.
#arba#e value
*rror
2@ "he desi#n o) classes in a a+ that hides the details o)
im$lementation )rom the user is ,non
as8
*nca$sulation
An)ormation Bidin#
Cata abstraction
Dll o) the above
.0 5hich o) the )olloin# ,e+ords do +ou thin, can be
used hen declarin# static members in a
class6
(i) Eublic
(ii) Erivate
(iii) Erotected
i2 ii and iii.
i and ii.
Fnl+ i.
i and iii.
1 5hat is the si(e o) em$t+ class
0
1
2
3
2 D ---- o$erator is called as deGre)erencin# o$erator.
G>
?
.?
.
. 4ame man#lin# is done b+ the ---------.
=++ com$iler
F$eratin# H+stem
=++ Iin,er
4one o) the above
3 D $ro#ram can use the address o) an+ variable in an
e:$ression2 e:ce$t variables declared
ith the ------- stora#e class.
auto
static
re#ister
e:tern
0 Fne cannot $er)orm $ointer arithmetic on a
------$ointer
char
void
int
)loat
9 "he ne o$erator thros a ------------ hen hea$ is
e:hausted.
runtime e:ce$tion
an+ e:ce$tion
; 5ith $rivate inheritance2 $ublic and $rotected members
o) the base class become -------
members o) the derived class.
$rivate
$rotected
$ublic
none o) the above
< An a -------- list2 the last node has a $ointer to the )irst
node.
Hin#le
Couble
=ircular
4one o) the above
@ ---------- are $ointerGli,e obJects used to access
in)ormation stored in a
container.
Aterators
$ointers
cur$tr
current$ointer
10 ------- and ------ are to error obJects.
clo#
cerr
cerror
cerrobJ
11 D Kriend )unction can have access to $rotected member
o) a class
"rue
Kalse
12 5hat ill be the oL$
class sam$le
{
$ublic8
int i;
void dis$la+()
{
delete this;
}
}
main()
{
sam$le ?s = ne sam$le;
sG>dis$la+();
sG>i = 0;
cout<<sG>i;
}
0
=om$ile time error
>un time error
4one o) these
1. 5hat ill be the oL$ o) the )olloin# $ro#ram
class sam$le
{
$ublic8
int i;
void dis$la+()
{
delete this;
}
}
main()
{
sam$le ?s = ne sam$le;
sG>dis$la+();
sG>i = 0;
cout<<sG>i;
sam$le s1;
s1.dis$la+();
}
0
=om$ile time error
>untime error
4one o) these
13 =++ is $ure obJect oriented $ro#rammin# lan#ua#e
true
)alse
10 #include<iostream.h>
void main()
{
L? this is L? an e:am$le ?L o) nested comment ?L
cout<<12.<<endl;
}
12.
=om$ile time error
>un time error
4one o) these
19 #include<iostream.h>
void main()
{
int a = 20;
int Mn = a;
n=a++;
a=n++;
cout<<a <<N2N<<n<<endl;
}
20220
20221
21222
4one o) these
1; #include<iostream.h>
void main()
{
int a = 202b=100;
int Mn = a;
n=a++;
n = ?Mb;
cout<<a <<N2N<<n<<endl;
}
212100
100221
1002100
=om$ile time error
1< main()
{
int main;
main = 100;
cout<<main++<<endl;
}
101
100
4one
*rror8 one cannot use main as identi)ier
1@ *valuate the mOn++ e:$ression2 assumin# m=23 and
n=;
3
.
2
4one
20 *valuate the mO++n e:$ression2 assumin# m=23 and
n=;
3
.
2
4one

You might also like