Computer Science, asked by aryaman2007satapathy, 2 months ago

If x=4 then what will be the output of X/2, x//2 and x%2. Give the reason.

Answers

Answered by anindyaadhikari13
3

ANSWERS.

  1. x/2 = 2.0
  2. x//2 = 2
  3. x%2 = 0

EXPLANATION.

Here, the value of x is 4.

'/' operator is used to perform division and returns floating point result.

So,

x = 4

print(x/2)

> 2.0

'//' operator is used to perform floor division. It is used to calculate the quotient after division.

So,

x = 4

print(x//2)

> 2

'%' operator is used to calculate the remainder obtained after division.

So,

x = 4

print(x%2)

> 0 As 4 divided by 2 leaves 0 as remainder.

Answered by purveshKolhe
3

 \green{ \boxed{ \mathfrak{ \red{answer : }}}}

Your answer is as follows::

Question::

If x = 4, then what will be the output of x / 2, x // 2 and x % 2

Answer::

x / 2

==> 4 / 2

==>2.0

It gives the answer on dividing.

x // 2

==> 4 // 2

==> 2

It outputs the quotient.

x % 2

==> 4 % 2

==> 0

It gives remainder as output. "%" is called modulo sign

 \green{ \boxed { \mathfrak{ \red{ remember : }}}}

"//" in java is used for comment and therefore it can't be used quotient in java.

The given question is in python. "%" and "/" can be used for same in java.

hope \:  \: this \:  \: helps \:  \: you

Similar questions