Solution for Exercise 11-22

ex1122

#include <stdio.h>

int main()
{
    int result;

    result=20-5*2+42/6;
    printf("20-5*2+42/6=%d\n",result);
    return(0);
}

Notes

* Sure, you could have just displayed the result, but this code adds in the equation.

* Here is the output:

* Both 5*2 and 42/6 are calculated first. The result is 20-10+7, which is read left-to-right by both humans and computers for a result of 17.