Ask Question
9 July, 15:13

Consider the following C program. #include int main (void) i<=99) printf ("%d", (i-i/10*10) * 10+i/10); else printf ("out of range"); return 0; a - What is the output if the input i = 9? b - What is the output if the input i = 151?

+2
Answers (1)
  1. 9 July, 17:30
    0
    When i=9 it is 90, when i=151 it is 25.

    Explanation:

    The program asks the user to enter the value of the i. Then, i is checked. If i is greater than 10 or smaller than or equal to 99, the value of the equation, (i-i/10*10) * 10+i/10), is printed. Otherwise, "out of range" is printed.

    For i=9, since the value is smaller than or equal to 99, the if part will be executed. If you substitute 9 for the i in the equation, the output will be 90.

    → (9-9/10*10) * 10+9/10) (Since both numbers are integers in 9/10, it is 0, not 0.9)

    → (9-0*10) * 10+0)

    → (9) * 10

    → 90

    For i=151, since the value is greater than 10, again the if part will be executed. If you substitute 151 for the i in the equation, the output will be 25.

    → (151-151/10*10) * 10+151/10) (Since both numbers are integers in 151/10, it is 15, not 15.1)

    → (151-15*10) * 10+15)

    → (151-150) * 10+15)

    → 1*10+15

    → 25
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the following C program. #include int main (void) i ...” 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