Performing simple calculations in C is done via arithmetic expressions very similar to what is done in other programming languages. C has a well-defined hierarchy of operations, but even if you memorize that whole hierarchy and are entirely comfortable with the priorities of the operators, it is a good idea to make good use of parentheses to make it clear to us mere mortals just what you mean.
This is a program to print numbers and their squares, from 0 up to whatever is input on the commandline.
That was an easy adaptation of the code I gave you. Nevertheless, you did have to work with and modify both an if and a for structure. So you now understand both conditional and looping structures in C. They are a lot like the corresponding structures in Java.
Just as in Java, you can nest structures within each other. Study this program, compile it, and run it. If you were to name it two.c and compile it to an executable called two then two 4 will produce 1/1 1/2 1/3 2/1 2/2 2/3 3/1 3/2 3/3.
Be sure you can answer all these questions before you proceed. If you have trouble with any then you must consult your lab instructor:
When you're comfortable with the above, you can tackle the next exercise.
Sample run:
> pythag 14 (3, 4, 5) is Pythagorean (5, 12, 13) is Pythagorean (6, 8, 10) is Pythagorean
Notice that (6, 8, 10) is basically the same triple as (3, 4, 5). For extra credit, see if you can suppress the printing of triples that can be obtained from previous triples by multiplying each member by a constant.