Solution for Exercise 8-2

ex0802

#include <stdio.h>

int main()
{
    int a,b;

    a = 6;
    b = a + 2;

    if( a > b)
    {
        printf("%d is greater than %d\n",a,b);
    }
    return(0);
}

Notes

* No, you did nothing wrong. The program doesn't generate any output. Can you explain why before reading the next bullet point?

* Look at the code!

* Because the value of variable a is not greater than the value of variable b, nothing is displayed. The statement in the curly brackets isn't executed because the if condition is false. Keep reading in the book for more information.