Table of Contents

Background

Determining factor pairs

“main number” % “number” == 0 means that the “number” is a factor.

Compiling

Can do gcc cnv0 then it will pop out a.out then do ./a.out and your prompt should come out. Can also use Make

Loops

for() loops

a for() loop has the format of for(start; loop condition; step){CODE HERE}.

An example would be for(factor = 1; conditions; factor = factor+1){CODE HERE}. This ensures that every time your condition is run the steps continue to progress until the conditions are not met anymore.

while() loops

A “while” loop is a kind of loop that runs until the parameters of an expression are fulfilled. For example, if you have:

number = 6
factor = 1

while (factor <= number)
{
factor = factor + 1
};

This means that the factor variable, in this example “1,” will continue to pass through the looping process, adding a value of 1 each time. This will occur 5 times until factor becomes equal to 6, fulfilling the parameters originally set.

Recall, double and (&&) can be used with loops to give more than one condition; however, be cautious when using && as it can sometimes overcomplicate your code.

do-while loops