Ask Question
21 September, 10:15

Write an if/else statement that assigns 0 to x when y is equal to 10; otherwise it should assign

1 to x.

+4
Answers (1)
  1. 21 September, 13:16
    0
    if (y==10)

    {

    x=0; / / assigning 0 to x if y equals 10.

    }

    else

    {

    x=1; / / assigning 1 to x otherwise.

    }

    Explanation:

    In the if statement i have used equal operator = = which returns true if value to it's right is equal to value to it's left otherwise false. By using this operator checking value of y and if it is 10 assigning 0 to x and if it is false assigning 1 to x.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write an if/else statement that assigns 0 to x when y is equal to 10; otherwise it should assign 1 to x. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers