User Tools

Site Tools


notes:cprog:fall2023:projects:cnv0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
notes:cprog:fall2023:projects:cnv0 [2023/09/10 20:35] – created wedgenotes:cprog:fall2023:projects:cnv0 [2023/09/28 01:25] (current) – [Compiling] xcroft
Line 3: Line 3:
 ====Determining factor pairs==== ====Determining factor pairs====
  
 +"main number" % "number" == 0 means that the "number" is a factor.
 =====Compiling===== =====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===== =====Loops=====
  
 ====for() 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==== ====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==== ====do-while loops====
  
notes/cprog/fall2023/projects/cnv0.1694378106.txt.gz · Last modified: 2023/09/10 20:35 by wedge