Lungi Dance

observe the following coding in Java and find how many times will "Lungi Dance" printed??

     int a=12<<3+7>>8;
    for(int i=1;i<=a;i++)
    System.out.println("Lungi Dance");

log on to comprogzz.in for more "Lungi Dance" program


The answer is 48.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Sudip Maji
Jul 28, 2014

Left shift num by n means: Multiply num by 2 n 2^n

Right shift num by n means: Divide num by 2 n 2^n

Now here we have nothing special to do with the loop, if we calculate a then it's the answer straightway cause a means the number of iterations of the loop

a = 12 < < 3 + 7 > > 8 a = 12<< 3+7 >> 8

a = 12 < < 10 > > 8 a = 12 << 10 >> 8

That means:

a = 12 2 10 2 8 a = \frac {12 * 2^{10}}{2^8}

a = 12 2 2 a = 12 * 2^2

a = 12 4 a = 12 * 4

a = 48 a= 48

thank you :D

Abhi Shek - 6 years, 9 months ago
Code 0987
Jul 11, 2014

i = 1 ; i < = a a i t e r a t i o n s \because i=1;i<=a\\\Rightarrow a \ iterations a = 12 < < 3 + 7 > > 8 = 12 < < 10 > > 8 = 12288 > > 8 = 48 \\\begin{aligned}\therefore a &=12<<3+7>>8 \\&= 12<<10>>8 \\&= 12288>>8 \\&= 48\end{aligned}

Kartikay Shandil
Jul 9, 2014

THe Correct answer is 49 .... P.S. DO not log on to comprogzz.in ....

how?Please explain.

Chaitnya Shrivastava - 6 years, 10 months ago

thnku so much....:)

Raj Maiti - 5 years, 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...