Ask Question
28 November, 10:39

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?

+5
Answers (1)
  1. 28 November, 13:15
    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?
Get an answer to your question ✅ “Consider the following C program. #include int main (void) i ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers