Вы находитесь на странице: 1из 13

In C programming language x = y + 1 ; means

(1)x= x-y+1
(2)x=-x-y-1
(3)x=-x+y+1
(4)x= x-y-1
"-=" is a shorthand assignment operator...
a-=b implies a=a-b
Therefore x-=y+1 => x=x-(y+1)
x = x-y-1
Ans : () x=x-y-1
7^a+4* ^!=171 "alue o# a!=
!"(a+)# $"b = 1!1$ = %%#$ = !"% # $"1
=> a+=% & b=1
=> a=-1 & b=1
=> ab = -1
i# a!$% are gp &'en loga$ log!$ log% are in
(p&ion
a) ap
!) gp
%) 'p
)) *one
a'b'( are in )*
=> b"+ = (#a
ta,ing log both sides
=> +#logb = log( + lo(a
if x'y'- are in A*' then +y=x+-
=> loga'logb'log( are in A*.
+rrays %an !e ini&iali,e) pro"i)e) &'ey are
(1) +u&oma&i%
(2) -x&ernal
(3) .&a&i%
(4) /o&' (2) an) (3)
(1) A.tomati(
A.to array /ariables (an be initiali-ed...0y defa.lt all the /ariables are a.to e/en if it is not
de(lared 1ith "a.to" ,ey1ord...
Ans : (1) A.tomati(
x$yan) , are &'ree 0uan&i&ies12 "aries in"ersely 3i&' 4 3'en 5 is %ons&an&14
"aries in"ersely 3i&' 5 3'en 2 is %ons&an&16'en 4=7$an)
5=7$2=3819in) 2 i# 4=1: an) 5=211
be(a.se x /aries in/ersely 1ith y 1hen - is (onstant
let xy = "a" (ass.ming arbitrary (onstant) ..... (1)
be(a.se y /aries in/ersely 1ith - 1hen x is (onstant
let y- = "b" (ass.ming arbitrary (onstant) ..... (+)
hen(e from (1) & (+)
x /aries dire(tly 1ith - 1hen y is (onstant
first set of /al.es are x=%2 y=3 -=!
let y do.bles and - remain (onstant i.e. y=(+#3) = 14 and -=!
hen(e x be(omes %25+ = 1$ (/aries in/ersely)
no1 - triples and y be(omes (onstant i.e. -=(%#!) = +1 and y=14
hen(e x be(omes 1$#% = $ (/aries proportionally)
hen(e ' y=14 -=+1 implies x=$
;C< o# &3o num!ers is 128 an) &'eir =C9 is 181 6'i%' one o# &'e #ollo3ing
!e &'e sum o# &3o num!ers>
(p&ion
a) 148
!) 78
%) :8
)) 78
6et the n.mbers be x and y
x#y = l(m#h(f = 1+22
xy = 1+22
7in(e the h(f of n.mbers = 12 ' the n.mbers are m.ltiples of 12
8a(tors of 1+22 that are m.ltiples of 12
(1+2'12)'(42'+2)'(2'%2)
7in(e l(m = 1+2
n.mbers are (2'%2)
s.m of n.mbers = %2+2=!2
+ !iase) )ie 'as a pro!a!ili&y o# 1?4 o# s'o3ing a $ 3'ile &'e pro!a!ili&y o#
any o# 1$ 2$ 3$ 4$ or : &urning up is &'e same 1 I# &'ree su%' )i%e are
rolle)$ 3'a& is &'e pro!a!ili&y o# ge&&ing a sum o# a&leas& 14 3i&'ou&
ge&&ing a : on any )ie >
!5142
*robability of getting $ = 15
*robability of getting 1'+'%' or 4 = 1 - 15 = %5
Therefore
probability of getting 1 = (%5)5$ = %5+2
probability of getting + = (%5)5$ = %5+2
probability of getting % = (%5)5$ = %5+2
probability of getting = (%5)5$ = %5+2
probability of getting 4 = (%5)5$ = %5+2
9/ent: % di(e rolled and their s.m sho.ld be atleast 1 1itho.t getting a 4 on any di(e.
ie ($'$'$) ' ('$'$)'($''$)'($'$')
*robability of getting ($'$'$) = 15#15#15 = 154
*robability of getting ('$'$) = %5+2#15#15 = %5%+2
*robability of getting ($''$) = 15#%5+2#15 = %5%+2
*robability of getting ($'$') = 15#15#%5+2 = %5%+2
*robability of getting a s.m of atlest 1
= 154 + %5%+2 + %5%+2 + %5%+2
= !5142
@$ A an) B %an )o a pie%e o# 3orC in 18$ 28$ 38)ays respe%&i"ely1 In 'o3 many
)ays %an @ )o &'e 3orC i# 'e is assis&e) !y A an) B on e"ery 9i#&' )ay>
*:s 1 day 1or, = 1512
;:s 1 day 1or, = 15+2
<:s 1 day 1or, = 15%2
* + ; + <:s 1 day 1or, = 1512 + 15+2 + 15%2 = 4 + % + +542 =>11542
* alone ll 1or, for days nd then ; nd < ll =oin him...
7o *:s days 1or, = # 1512 = +5$
$th day => +5$ + 11542 = + + 11542 => %$542 => !51+
>n $ days' part of 1or, (ompleted = !51+
<emaining 1or, = 1 - !51+ => $51+
Again * ll 1or, for days... days 1or, = +5$
7o !51+ + +5$ => $?542
*art of 1or, (ompleted in ? days = $?542
<emaining 1or, = 1 - $?542 => 1542
12th day * + ; + < ll 1or, together ... Their 1 day 1or, = 11542
To (omplete 1542' they ll ta,e
1542 # 42511 = 1511
7o totally they ll ta,e ? + 1511 days to (omplete the entire 1or,
Ans : ? 1511 days
@ipe + &aCes 1: min &o #ill a &anC1 @ipe / an) C$ 3'ose %ross se%&ional
%ir%um#eren%e are in ra&io 2D3$ #ill ano&'er &anC &3i%e as !ig as &'e #irs&1
I# + 'as a %ross se%&ional %ir%um#eren%e &'a& is 1?3 o# C$ 'o3 long 3ill i&
&aCe #or / an) C &o #ill &'e se%on) &anC 1
%+51% min
Time ta,en by pipe A = 14min
Time ta,en by A to fill +nd tan, (t1i(e big) = %+min
<atio of (ross se(tional (ir(.mferen(e of 0 and @ = +:%
let it be +x and %x
)i/en (ross se(tional (ir(.mferen(e of A = 15% of @
=15%#%x
=x
<atio of @7 @ir(.mferen(e of A' 0 and @ = x:+x:%x = 1:+:%
<atio of (ross se(tional area of A'0 and @ = 1"+:+"+:%"+ =1::?
(0e(o-' sA.are of ratio as @ir(.mferen(e=+#pi#r and area = +#pi#r"+ )
ie if @ross se(tional area of A =x
@ross 7e(tional area of 0 and @ =x+?x = 1%x
6et y be the time ta,en by 0 and @ to fill +nd tan,
x ----- %+min
1%x ---- y min
y = x # %+ 51%x
=%+51%min
A1 =o3 many argumen&s )oes &'e #un%&ion #s%an#() 'a"e >
%
fs(anf(file pinter' "format spe(ifier"' address of identifier)
+n array arrE:FE2:F is sor&e) in &'e memory 3i&' ea%' elemen& re0uiring 2
!y&es o# s&orage1# &'e !ase a))ress o# array in memory is
2888$)e&ermine lo%a&ion o# arrEFE7F 3'en &'e array is s&ore) in %olumn
maGor #orma&1
(p&ion
a)28H4
!)22:4
%)2878
))4812
Batrix to be fo.nd :: ACDECFE .. )i/en Bat has < ro1s and @ (ol
(ol.mn ma=or :: 0ase + G(F<+D)
therefore +222 + +#(!#4 + $)
+2?4 Ans
6'i%' o# &'e #ollo3ing is no& a "ali) &ype o# polymorp'ism>
a) a)'o% polymorp'ism
!)impera&i"e polymorp'ism
%) pre)i%&a&&i"e polymorp'ism
)) in%lusion polymorp'ism
HAd-ho( *olymorphism : >f a f.n(tion denotes different and potentially heterogeneo.s
implementations depending on a limited range of indi/id.ally spe(ified types and
(ombinations' it is (alled ad ho( polymorphism. Ad ho( polymorphism is s.pported in many
lang.ages .sing f.n(tion o/erloading.
H>n(l.sion *olymorphism : 7.btyping (or in(l.sion polymorphism) is a (on(ept 1herein a
name may denote instan(es of many different (lasses as long as they are related by some
(ommon s.per(lass. >n ob=e(t-oriented programming' this is often referred to simply as
polymorphism.
H*arametri( *olymorphism : *arametri( polymorphism is a 1ay to ma,e a lang.age more
expressi/e' 1hile still maintaining f.ll stati( type-safety. Ising parametri( polymorphism' a
f.n(tion or a data type (an be 1ritten generi(ally so that it (an handle /al.es identi(ally
1itho.t depending on their type.
Types of *arametri( *olymorphism:
*redi(ati/e *olymorphism : >n a predi(ati/e parametri( polymorphi( system' a type
(ontaining a type /ariable may not be .sed in s.(h a 1ay that is instantiated to a
polymorphi( type.
>mpredi(ati/e *olymorphism : >mpredi(ati/e polymorphism (also (alled first-(lass
polymorphism) is the most po1erf.l form of parametri( polymorphism.C$E A definition is said
to be impredi(ati/e if it is self-referentialJ in type theory this allo1s the instantiation of a
/ariable in a type 1ith any type' in(l.ding polymorphi( types' s.(h as itself.
7o' Ans1er is b) @o-' >ts >mpredi(ati/e *olymorphism' Got >mperati/e
I# main memory a%%ess &ime is 18ms an) %a%'e memory is 28 &imes #as&er &'an
main memory an) %a%'e %an !e use) 78I o# &'e &ime1 Cal%ula&e &o&al
a%%ess &ime using %a%'e memory (in ms)
main memory=12 ms
(a(he memory +2 times faster than main so main memory
let .s (onsider
122K----12ms
1K------L
1K=2.1
so +2 times means +2#1K
+2#2.1=+ms
total (a(he time=325122#+=1.4ms
6'a& is &'e nex& num!er o# &'e #ollo3ing se0uen%e
7H$:4$2:$1$>
!?'4'+4'1$'L
!? => !#?+1=4
4 => 4#++=+4
+4 => +#4+%=1$
1$ => 1#$+= ?
ans: ?
logx^2(71-24x)=1
logx^2(81-24x)=1
=> logx^2(81-24x) = logx^2(x^2)
=> 81-24x = x^2
=> x^2+24x-81=0
=> (x+27)(x-3)=0
=> x = -27, 3
so, x= -27 , 3
In 3'i%' no sys&em (242+444) )i"isi!le !y 18
(p&ion
a) 'exa sys&em
!) )e%imal sysy&em
%) o%&al sys&em
)) pen&a sy&em
+++=434base12
in hexade(imal
4#14"++3#14"1+4#14"2=1$%4+1+3+4=14!2 1hi(h is di/isible by 12
hen(e option a) is (orre(t
In .1- %rea&es a lan game &'ere are 7 )i)gi& %o)e ma)e up o# 1$2$3$4$$:$7$7 'as
&o !e )e%i)e) on$as a uni"ersal %o)e1'o3 many op&ions )oes 'e 'a"e i#
ea%' no 'as &o !e use) an) no num!er %an !e reape&e)>>>
(p&ion
a) 7p7
!) 7%7
%) 7p7 - 7
)) 7* 7%1
ans:a
1e ha/e to arrange 3 n.ms in different 1ays s.(h that no n.m (an be repeated..
(onsider there are 3 pla(es..
to fill 1st pla(e 1e ha/e 3 (han(es
+nd pla(e==> ! (han(es(b(o- one digit is already pla(ed in 1st pla(e and repetition is not
allo1ed)
similarly.... %rd pla(e==> 4 (han(es
th pla(e==> $ (han(es
.
.
so on....
#r####eA.ired no.of 1ays=3#!#4#$##%#+#1= 3M=3p3
6'en &'e pri%e o# a pro)u%& 3as in%rease) !y 1I &'e num!er o# i&ems sol)
3'ere )e%rease) !y 28I 1 3'a& is &'e ne& e##e%&>
6et initial pri(e be 122<s therefore after in(rease in pri(e of prod.(t 1ill be 11$<s.
Amo.nt in(.rred after selling the prod.(t(before pri(e in(rease)=122#122<7
Amo.nt in(.rred after selling the prod.(t(after pri(e in(rease)=11$#32<s
Therefore there is a loss of 3K(ans1er)
6'a& is &'e nex& num!er o# &'e #ollo3ing se0uen%e
343$ 1331$ 21H7$ 41H3$ :7H$ >
ans-1+14!
!"%=%%
11"%=1%%1
1%"%=+1?!
1!"%=?1%
1?"%=43$?
+%"%=1+14!
yhese are the (.be of prime n.mbers
A1 Consi)er a 'as'ing #un%&ion &'a& resol"es %ollision !y 0ua)ra&i% pro!ing1
+ssume &'e a))ress spa%e is in)exe) #rom 1 &o 71 6'i%' o# &'e #ollo3ing
lo%a&ions 3ill ne"er !e pro!e) i# a %ollision o%%urs a& posi&ion 4>
(p&ion
+1 4
/1
C1 7
J1 2
for A.adrati( probing (ollision is resol/ed as h+1"+' h++"+ ' h+%"+ ...
so option A'N lo(ation7 1ill ne/er be probed
K'e le&&ers o# &'e 3or) 6(<+* are 3ri&&en in all possi!le
or)ers an) &'ese 3or)s are 3ri&&en ou& as in a )i%&ionary
$&'en &'e ranC o# &'e 3or) L6(<+*L is
a1 117
!1 128
%1 117
)1 11H
Go. of 1ords starting 1ith A => M
B => M
G => M
O => M
PA => %M
PB => %M
PG => %M
PO => %M
POA => +M
next is POBAG
ran, of POBAG = #(M) + %#(%M)+ +M + 1 = 11!
(a)
I# xI o# a is &'e same as yI o# !$ &'en ,I o# ! is D
a1 (xy?,)I o# a
!1 (y,?x)I o# a
%1 (x,?y)I o# a
)1 *one o# &'ese
xK of a = yK of b => x#a5122 =y#b5122 => ax=by => b=a#(x5y)
then -K of b = -K of a#(x5y)=(-x5y)#(a5122) = (x-5y)K of a
(()
K'e ari&'me&i% mean o# 2 num!ers is 34 an) &'eir
geome&ri% mean is 1:1 (ne o# &'e num!ers 3ill !e
a1 4
!1 1:
%1 17
)1 12
x+y=+#% =43
& (x#y)"(15+)=14 => xy=+$4 =>x#(43-x)=4# => x='4
(a)
In a Cilome&re ra%e$ i# + gi"es / a 48 m s&ar&$ + 3ins !y 1H
s1 /u& i# + gi"es / a 38 s s&ar&$ / 3ins !y 48 m1 9in) &'e &ime
&aCen !y / &o run $888 m>
a1 18 s
!1 48 s
%1 78 s
)1 72 s
let speed of A = x m5s & speed of 0 = y m5s then
12225x +1? = (1222-2)5y => 12225x = ?425y -1? ----(1)
(1222-%2#y)5y = (1222 -2)5x => ?425x = 12225y -%2 ----(+)
di/iding (1) by (+)
=> 12225?42 = (?42 - 1?y) 5 (1222 - %2y)
=> +$(1222 -%2y) = +(?42 -1?y)
=> y = +25% m5s
so' x = 3 m5s
time ta,en by 0 to r.n $222 m
= $2225y
= $2225(+25%)
= $222#%5+2
= !$2 se(
(()
.eema %anno& %omple&ely remem!er 'er #our-)igi& +K< pin num!er1 .'e
)oes remem!er &'e #irs& &3o )igi&s$ an) s'e Cno3s &'a& ea%' o# &'e las&
&3o )igi&s is grea&er &'an 1 K'e +K< 3ill allo3 'er &'ree &ries !e#ore i&
!lo%Cs #ur&'er a%%ess1 I# s'e ran)omly guesses &'e las& &3o )igi&s$ 3'a&
is &'e pro!a!ili&y &'a& s'e 3ill ge& a%%ess &o 'er a%%oun&>
(p&ion
11 1?2
21 2?3
31 3?1:
41 1?1:
Ans is %514.
0e(a.se it is gi/en that "ea(h of the last t1o digits is greater than $" means %rd digit is >$(4
or ! or 3 or ?) and th digit is also >$.
7o the last t1o digit n.mbers are (44'4!'43'4?'!4'!!'!3'!?'34'3!'33'3?'?4'?!'?3'??) so total
14 n.mbers and there are three (han(es means 1e ha/e to pi(, % n.mbers probability of
pi(,ing % n.mbers from 14 is %514.
A)3'a& is &'e grea&es& posi&i"e po3er o# &'a& )i"i)es 38M exa%&ly1
(p&ion
a)
!):
%)7
))7
%2 fa(torial is 1 # + # % # ... # +? # %2
8ind all the n.mbers in this range that are m.ltiples of $'
$' 12'1$'+2'+$'%2.
$ has one $
12 has one (ommon fi/e
1$ has one (ommon fi/e
+2 has one (ommon fi/e
+$ has t1o (ommon fi/es
%2 has one (ommon $
Ans1er is $ " ! th po1er.
A1 6'a& is &'e "alue o# log(a+!)?%+log %?a13'en i& is gi"en &'a& L!L is #our &imes
&'e "alue o# LaL1
(p&ion
a) log 2
!) log 3
%) log 4
)) log
e) log 18
log(a+b)5(+log (5a
=logC(a+b)5( #(5aE
=logC(a+b)5aE
=log(1+ b5a)
=log(1+) Cgi/en' b=a => b5a=E
=log$
d)log $
21D474DD37D11
a)2:
!)27
%)2
))22
ans-A-+4
++1+$=3
+!+=1$
$+%+!=1$
++4=3
J17= D N27C DD B:8O D 111
(p&ion
a) P1114
!) P:H4
%) Q:H4
)) Q1114
ans is b.
be(a.se (N+%)means(+%)=)(!)
13+?=+! '
and (Q+%) means (3+%)=R(11) ==> )+!R
so that:s 1hy
(<+%)means (13+%)=+1(I)
(42+?)= 4?
(/+%) means (+++%)=+$(F)
so ans is I4?F
9in) 3'a& is nex& num!er
2888$228$888$>
+222#1++$2=++$2
++$2#++$22=$222
$222#%+1222=14222
3'i%' o# &'e #ollo3ing s&a&emen& is no& &rue a!ou& &agge) union>>>
a)i& is Cno3n as "arian&1
!)(nly one )a&a &ype is use) a& a &ime1
%)i& 'ol)s "alue o# a "aria!le si,e) )i##eren& )a&a &ypes1
))&'e &ag #iel) )e&ermines 3'i%' )a&a&ype is !eing %urren&ly use)1
Tagged .nion also (alled /ariant' /ariant re(ord is a data str.(t.re .sed to hold a /al.r that
(o.ld ta,e on se/eral different b.t fixed types. Only one of the types (an be in .se at any
one time' and a tag field expli(itly indi(ates 1hi(h one is in .se.
7o (learly Option - @ is @orre(t Ans1er.
+ !oy 'as 4 )i##eren& !oxes an) )i##eren& mar!les1 In 'o3 many 3ays %an 'e
pla%e &'e mar!les in &'e !oxes su%' &'a& ea%' !ox 'as a& leas& one
mar!le >
(p&ion
a) :8
!) 248
%) 428
)) 3:
different boxes and $ different marbles to be pla(ed s.(h that ea(h box has at least one
marble
so three box 1ill (ontain one marble & one box 1ill + marbles
$=1+1+1++
(+'1'1'1) => $@+#%#+#1=42
(1'+'1'1) => $#@+#+#1=42
(1'1'+'1) => $##%@+#1=42
(1'1'1'+) => $##%#+@+=42
total no of 1ays= 42+42+42+42=+2
op+: +2
+n un!iase) %oin is &osse) n &imes1 I# &'e pro!a!ili&y o# ge&&ing 4 &ails e0uals
&'e pro!a!ili&y o# ge&&ing 7 &ails$ &'en &'e pro!a!ili&y o# ge&&ing &3o &ails
isD
n@S(15+)"TS(15+)"(n-)T=n(!S(15+)"!TS(15+)"(n-!)T
n@=n@!
-> n=+!=11
11@+S(15+)"+TS(15+)"?T
11@+S(15+)"11T :Ans
9our )i##eren& ele%&roni% )e"i%es maCe a !eep a#&er e"ery 38 minu&es$ 1 'our$
3?2 'our an) 1 'our 4 minu&es respe%&i"ely1 +ll &'e )e"i%es !eepe)
&oge&'er a& 12 noon1 K'ey 3ill again !eep &oge&'er a&D
(p 1D 12 mi)nig'&
(p 2D 3 a1m1
(p 3D : a1m1
(p 4D H a1m1
%2 min.tes' 1 ho.r' %5+ ho.r and 1 ho.r $ min.tes
15+ hr ' 1 hr ' %5+ hr ' !5 hr
find 6@B of 15+ ' 1 ' %5+ ' !5 = +1 hr
sin(e all the de/i(es beeped together at 1+ noon' they 1ill again beep together
after +1 ho.r
reAd time = 1+ noon + +1 hr = ? a.m
Op : ? a.m.