Solution for Exercise 11-9

ex1109

#include <stdio.h>

int main()
{
    float alpha;

    alpha=501;
    printf("alpha = %.1f\n",alpha);
    alpha+=99;
    printf("alpha = %.1f\n",alpha);
    alpha-=250;
    printf("alpha = %.1f\n",alpha);
    alpha/=82;
    printf("alpha = %.1f\n",alpha);
    alpha*=4.3;
    printf("alpha = %.1f\n",alpha);
    return(0);
}

Output

alpha = 501.0
alpha = 600.0
alpha = 350.0
alpha = 4.3
alpha = 18.4

Notes

* As with an example from Chapter 10, the %.1f conversion character is used in the printf() statements. This conversion character formats output so that it's not peppered with zeros. Chapter 13 discusses the printf() function's conversion characters and their options.