To generate a list of Pythagorean triples m
could be allowed to take values from its minimum possible value (2) up to some maximum value entered by the user. For each value of n
from 1 up to m-1
the corresponding triple could then be evaluated and output. An algorithmic description for this is:
enter and validate a maximum value for m.
for each value of m from 2 to maximum do
{
for each value of n from 1 to m-1 do
{
evaluate and print a triple.
}
}
This description uses a for
loop, a looping construct that repeats the loop statement as some control variable takes a sequence of values. Also note that one for loop is nested inside another, this is very common. From this description the following help to develop C program.