Solution of output finding questions in java

1.

int k=5;

int d = –k + ‘A’ / k++; 

System.out.println(d);

2.

int k = 7;

int d = (‘D’ – k++) + –k * 2;

System.out.println(d);

3.

int k = 3;

int d = ‘E’ / (k++ + 1) + –k;

System.out.println(d);

4.

int k = 5;

int d = –k + ‘B’ / k++ + ++k – ‘A’;

System.out.println(d);

5.

int a = 3;

int b = ++a * a– % 4 + ‘C’ / a++ – –a;

System.out.println(b);

6.

int x = 7;

int y = ++x + x– – ‘A’ % x++ + x / –x * 2;

System.out.println(y);

7.

int a = 4;

int b = a++ + –a * 3 % 2 + ‘B’ / a– – ++a * 2;

System.out.println(b);

8.

int a=20;

int s = (Math.round(19.7) == a) ? a * 10 : a % 10;

System.out.println(s);

9.

int a = 22;

int s = (Math.round(21.6) == a) ? ((a++ + 3) % 4) * 2 : ((–a / 3) + a % 5);

System.out.println(s);

10.

int a = 7;

int s = (Math.max(5, 7) == a) ? a++ % 3 + 4 : –a + 1;

System.out.println(s);

11.

int a = -10;

int s = (Math.abs(a) == 10) ? Math.min(5, 8) * 2 : a % 3 + 6;

System.out.println(s);

12.

int a = 25;

int s = (Math.sqrt(625) == a) ? a / 5 + 1 : a % 4 * 2;

System.out.println(s);

13.

int a = 11;

int s = (Math.floor(10.9) == a) ? ++a % 5 * 2 : a– / 2 + 4;

System.out.println(s);

14.

int a = -3;

int s = (Math.abs(a) == 3) ? (int)Math.pow(2, 3) : Math.max(4, 6) + a;

System.out.println(s);

15.

int x = 9;

int y = 4;

if (x % y > 1)

    System.out.println(x / y + y % x);

else

    System.out.println(x * y – y);

16.

int a = 15, b = 7;

if (++a % 2 == 0)

    System.out.println(a + b–);

else

    System.out.println(–b * a);

17.

int m = 12;

double n = 13.5;

if (Math.floor(n) == m)

    System.out.println((int)(Math.pow(m, 2)));

else

    System.out.println((int)Math.sqrt(m * 10));

18.

int p = 20;

int q = 10;

if (Math.max(p, q) == q)

    System.out.println(p % q + 5);

else

    System.out.println(p / q + 5);

19.

int a = 10;

int b = 5;

if (Math.abs(a – b * 3) > 5)

    System.out.println((int)Math.ceil(10.3));

else

    System.out.println((int)Math.floor(9.8));

20.

int x = 8;

int y = 3;

if ((x++ % 3 == 2) && (–y == 2))

    System.out.println(x + y);

else

    System.out.println(x * y);

21.

int a = 18;

if (Math.sqrt(a) > 4)

    System.out.println((int)Math.pow(2, 3));

else

    System.out.println((int)Math.floor(7.9));

22.

int x = 5;

if (Math.pow(x, 2) > 20)

    System.out.println(x– * 2);

else

    System.out.println(++x * 2);

23.

int p = 7;

if ((++p % 3 == 0) || (Math.abs(-14 + p) > 10)) {

    p += Math.max(2, p % 5);

} else {

    p = Math.min(p, 6);

}

System.out.println(“Result = ” + p);

24.

int a = 15;

double b = Math.pow(a, 0.5);

int x = (int)b;

int result = (x++ == Math.floor(b)) ? ++x * 2 : x– + 5;

if (result % 2 == 0) {

    result += Math.min(a, x);

} else {

    result -= Math.max(a, x);

}

System.out.println(result);

25.

int a = 12;

int b = 7;

int c = Math.round((float)Math.sqrt(a * b));

int res = ((a++ % 2 == 0) ? ++b : –c);

res += (Math.ceil(a / 2.0) == 7) ? 5 : -3;

System.out.println(res);

26.

int a = 5, b = 4;

int x = (int)Math.pow(a++, 2);

int y = (int)Math.sqrt(++b * 10);

int result = (x > y) ? x – y : y – x;

result += ((result % 2 == 0) ? 1 : 2);

System.out.println(result);

27.

int a = 5, b = 3;

int x = (int)Math.pow(++a, b–); 

double y = Math.sqrt(x) + Math.ceil(4.2);

int z = (int)(y % 7 + a– * b);

z = (z > 20) ? (int)Math.round(y + 2) : (int)Math.floor(y – 1);

System.out.println(z);

28.

int a = 10;

int b = 3;

int c = (a++ > 9) ? (b++ * 2) : (b– + 4);

int d = (int)Math.ceil(Math.pow(c, 0.5)) + –a;

d = (d % 2 == 0) ? d + Math.min(a, b) : d – Math.max(a, b);

System.out.println(d);

29.

int x = 14, y = 5;

int r = (x– > 10) ? (int)Math.pow(–y, 2) : (int)Math.sqrt(++x);

r += (r % 3 == 0) ? Math.min(x, y) : Math.max(x, y);

r = (r > 20) ? r – 3 : r + 3;

System.out.println(r);

30.

int a = 9;

int b = 4;

int r = ((a % 2 == 1) && (b++ > 3)) ? a– + b : ++a – b–;

r *= (Math.floorMod(a, 3) == 0) ? 2 : 3;

System.out.println(r);

Leave a Comment