Computer Science, asked by friendsforever7244, 6 months ago

pleasee Help
pleasee Don't SpaM​

Attachments:

Answers

Answered by anindyaadhikari13
2

Question:-

  • Find the output of the following code snippet.

Solution to Question 1:-

Given,

a=4, b=8

Now,

b - a--

=8-4

=4

Now,

a=3

Therefore,

b-a-->= a is true.

b=8,a=3

Now,

(b+a) %2

=11%2

=1

Therefore,

1==1 is true.

So,

If block will execute.

a*b=3*8=24

Output:-

24

Solution to Question 2:-

The above program contains syntax error as no conditions were written inside brackets in if statements.

Answer:- Compilation error.

Answered by Vyomsingh
3

Solution 1:

Given:

  • a=4
  • b=8

Working of Code:-

if((b-a--)>=a)//8-4>=3✔️

{

if((b+a)%2==1)//(8+3)%2==1✔️

{

System.out.println(a*b);// This part will execute ✔️

}

else

System.out.println(b+a);

}

____________

Hence,

a*b=> 8*3

=> 24

Output

24

___________________________

Solution 2:

Given:

int odd=1

Working of Code:-

if(odd)// odd is not Boolean type❎

{

System.out.println("odd");

}

else

{

System.out.println("even");

}

hence,

Compilation Error

Similar questions