Vous êtes sur la page 1sur 4

P23 C++

1 int main()
{
int limits[ ] = {1,2,3,4,5,6};
int result=0;
for (unsigned int ii=0; ii5;!!ii)
{
int total = 0;
total !=ii;
if (total " limits[ii])
result= ii;
}
}
#$at is t$e %alue of &result' after t$e (ode a)o%e is e*e(uted+
a) 4
)) 0
() 1
d) 3
a
)
(
d
2 %oid main( )
{ (out,setf(ios--$e*..ios--s(ientifi();
(out &/i' 100 endl;
}
#$at is t$e out0ut of a)o%e (ode+
a) /i 100
)) 123,12 /i 100
() 12,13e!01/i 100
d) 1,2312e!02/i 64
a
)
(
d
3 (lass animal {};
(lass 0et{};
(lass 1ame{};
(lass dog - 0u)li( 0et{};
(lass string {};
(lass 0etdogs - 0u)li( dog, 0u)li( animal
{0rote(ted-
string 1ame;
};
0etdogs lassie;
#$at is t$e order of (onstru(tor in%o(ation 2$en &lassie' is
(reated+
a) 0et( ), dog( ), animal( ), string( ), 1ame( ), and 0etdogs( )
)) 0et( ), dog( ), animal( ), string( ) and 0etdogs( )
() 0etdogs( ), 0et( ), dog( ), animal( ) and 3tring( )
d) 4rror a
)
(
d
4 (lass 5
{
($ar 60;
int len;
};
int main()
{
(onst int si7e=18;
5 6t)l2 = ne2 5[si7e];
(out si7eof(6t)l2);
}
(5ssume 9: (om0iler)
a) 4
)) 2
() 8
d) 18
a
)
(
d
5 5 (lass im0lementation is said to )e $idden from its
(lients or in ot$er 2ords t$e (lass is ;;;;;;;;;;;;,
a) <n$erited
)) a)stra(ted
() 4n(a0sulated
d) 1one of t$e a)o%e
a
)
(
d
6 %oid main( )
{
s2it($(3,2,1)
{
(ase 1-(out &one';
(ase 2-(out't2o';
(ase 3-(out't$ree';
default -(out'6';
}
}
#$at is t$e out0ut of t$e a)o%e (ode+
a) one
)) t2o
() onet2ot$ree6
d) 6
a
)
(
d
= int (ount=0;
(lass o)>
{
0u)li(-
o)>( ){(ount!!;}
?o)>( ) {(ount@@;}
};
%oid main( )
{
o)> 5,A,:,B,4;
o)> C;
{
o)> g;
}
return 0;
}
#$at is t$e %alue of &(ount' immediatelD after t$e return
statement a)o%e is e*e(uted+
a) 6
)) 5
() 0
d) 1
a
)
(
d
8 (lass E
{
0u)li(-
int *;
stati( %oid f(int 7);
};
%oid E--f(int D)
{
*=D;
}
#$at is t$e error in t$e sam0le (ode a)o%e+
a) F$e stati( mem)er fun(tion f( ) a((esses t$e non@stati( *,
)) F$e (lass E does not $a%e anD 0ri%ate mem)ers,
() F$e stati( mem)er fun(tion f( ) a((esses t$e non@stati( 7,
d) F$e mem)er fun(tion f( ) must return a %alue,
a
)
(
d
G Huess t$e out0ut,
I in(lude iostream,$"
%oid main ( )
{
int i=10;
for (;;)
i!!;
(out &ADe';
}
a) ADe 2ill )e 0rinted
)) 3ta(J o%erflo2
() <nfinite loo0
d) 4rror
a
)
(
d
10 ($ar sing [ ]='Ka(arena';
%oid main ( )
{
($ar sing[ ]= &Los';
{
($ar sing[ ]= &Bel';
{
($ar sing [ ]= &Mio';
(outsing;
}
}
}
#$at 2ill )e t$e out0ut+
a) 4rror
)) Ka(erena
() Los Mio
d) Mio
a
)
(
d
11 main( )
{
int i=0,>=0,J=0,result;
result=(i!!NN>!!NN!!J) ;
(out &result=' result;
(out &i=' i;
(out &>='>;
(out 'J='J;
}
a) result = 1 i=1 >=1 J=1
)) result = 1 i=1 >=0 J=1
() result =0 i=1 >=0 J=0
d) result=0 <=1 >=1 J=0
a
)
(
d
12 Idefine 5A3(a) (a)0 +@ (a) - (a)
Idefine HFM()) ())"G + (1) - (0)
int main()
{
int ans2er = HFM(5A3(10@20));
(outans2er;
}
2$at 2ill )e t$e out0ut of t$e 0rogram
a) 0
)) 1
() O1
d) 4rror
a
)
(
d
13 #$at is t$e time taJen )D )inarD sear($ algorit$m to
sear($ a JeD in a sorted arraD of n element+
a) 0 (log2 n)
)) 0(n)
() 0 ( n log2 n)
d) 0 (n2)
a
)
(
d
14 #$i($ of t$e follo2ing o0erations is 0erformed more
effi(ientlD )D a dou)lD linJed list t$an a linear linJed list+
a) deleting a node 2$ose lo(ation is gi%en
)) sear($ing an unsorted list for a gi%en item
() inserting anode after t$e node 2it$ a gi%en lo(ation
d) tra%ersing t$e list re%erslD to 0ro(ess ea($ node
a
)
(
d
15 5 linear list of elements, in 2$i($ deletion (an )e done
from one end, insertion (an taJe 0la(e onlD at t$e ot$er end is
Jno2n as
a) Pueue
))sta(J
() tree
d) dePue
a
)
(
d
16 F$e fi%e items-5,A,:,B and 4 are 0us$ed in sta(J t$e
ot$er starting from 5, F$e sta(J is 0o00ed four items and ea($
element is inserted in a Pueue, F$en t2o elements are deleted
from t$e Pueue and 0us$ed )a(J on t$e sta(J, 1o2 one item is
0o00ed from t$e sta(J, F$e 0o00ed item is-
a) 5
)) A
() :
d) B
a
)
(
d
1= <f ea($ node in a tree $as %alue greater t$an e%erD %alue
in its left su)tree and $as %alue less t$an e%erD %alue in its
rig$t su)tree, t$e tree is Jno2n as
a) (om0lete tree
)) full )inarD tree
() )inarD sear($ tree
d)unt$read tree
a
)
(
d
18 5 t$readed )inarD tree is )etter t$an a )inarD tree )e(ause
1, <t refuses t$e null linJs
2, Fra%ersal is easier for it using t$e t$reads,
3, 5 non@re(ursi%e tra%ersal (an )e im0lemented for it and t$e
same (annot )e im0lemented for a )inarD tree
a) all are true
)) onlD 1 N 2 are true
() onlD 2 N 3 are true
d) onlD 1 N 3 are true
a
)
(
d
1G <n 2$at order t$e elements of a 0us$do2n sta(J are
a((essed+
a) Cirst in first out(C<CQ)
)) Lat in last out(L<LQ)
() Last in first out (L<CQ)
d) 1one of t$e a)o%e
a
)
(
d
20 5n undire(ted gra0$ H 2it$ n %erti(les and e edges are
re0resented )D 5d>a(en(D list, #$at is t$e time rePuired to
determine t$e total num)er of edges in H+
a) Q(e)
)) Q (n)
() Q(n2)
d) Q(e!n)
a
)
(
d
21 #$i($ of t$e follo2ing statements is false+
a) e%erD tree is a )i0artite gra0$
)) a tree (ontains a (D(le
() a tree 2it$ n nodes (ontains n@1 edges
d) a tree is a (onne(ted gra0$
a
)
(
d
22 5 )inarD tree 2it$ t$e 0ro0ertD t$at t$e %alue at ea($
node is at least as large as t$e %alues as its ($ildren is Jno2n
as
a) )inarD sear($ tree
)) 59L tree
() :om0letelD tree
d) /ea0
a
)
(
d
23 F$ere (annot )e a (ir(ular
a) 3inglD linJ list
)) Rueue
() 3ta(J
d) Bou)lD linJed list
a
)
(
d
24 =, 5 &$as a' relations$i0 )et2een (lasses re0resents
;;;;;;;;;;;;;;;; and an &is a' relations$i0 )et2een (lasses
re0resent ;;;;;;;;;
a) (ontainers$i0,in$eritan(e
)) in$eritan(e,(ontainers$i0
() (ontainers$i0,Su)li( in$eritan(e
d) (ontainers$i0,0rote(ted in$eritan(e
a
)
(
d
25 Sre@order is not$ing )ut
a) de0t$ first order
)) )readt$ first order
() to0ologi(al order
d) liner order
a
)
(
d
26 F$e initial (onfiguration of Pueue is a,),(,d(TaU is at t$e
front), Fo get t$e (onfiguration d,(,),a one needs a minimum
of
a) 2 deletions N 3 additions
)) 3 deletions N 2 additions
() 3 deletions N 3 additions
d) 3 deletions N 4 additions
a
)
(
d
2= Sartition e*($ange sort is also Jno2n as
a) /ea0 sort
)) Au))le sort
() Madi* e*($ange sort
d) Rui(J sort
a
)
(
d
28 (lass Fest
{
0u)li(-
Fest()
{
(outVWn:onstru(ting FestV;
}
?Fest()
{
(outVWnBestru(ting FestV;
}
};
int main()
{
trD
{
Fest t1;
int *=10;
t$ro2 *;
}
(at($(int *)
{
(outV<n (at($V;
}
return 0;
}
#$at 2ill )e t$e out0ut of t$e 0rogram
a):ontru(ting Fest Bestru(ting test <n (at($
)):ontru(ting a
)
(
d
2G :onsider t$e follo2ing statements-
1, sta(J is a L<CQ
2, 3ta(J is a C<CQ
3, Rueue is a L<CQ
4, Rueue is a C<CQ
a) QnlD 1 N 3 are true
)) QnlD 2 N3 are true
() QnlD 1 N 4 are true
d) QnlD 2 N 4 are true
a
)
(
d
30 <n a singlD linJed list, if a ne2 node is to )e inserted
)et2een t2o (onse(uti%e nodes $o2 manD linJs $a%e to )e
modified+
a) 1
)) 2
() 3
d) 4
a
)
(
d

Vous aimerez peut-être aussi