In divisible, your task is to print out every number between 1 and 100 that is divisible
by 6. The first numbers in the sequence should be 6, 12, 18 ...
You don't need <cs50.h>!
- Create a new directory (
mkdir divisible) andcdinto it (cd divisible). - Execute
wget https://github.com/daltongit/checks/raw/c/divisible/divisible.cto download the distribution code
You should fill in all of the blanks and add code under the TODO's. If you want to add or delete lines of code, you can.
- The program starts by repeating between every number from 1 to 100. You should determine if the
forloop should be<=or<100 though. - We define a variable
____with typefloat. You should replace this with a better (more descriptive) variable name. - We then set
____to the current number (i) divided by6. You may find this to be helpful when you are filling in theifstatement below. - We then set an if loop. You have to fill in the condition though. The condition should check if
idivided by 6 is a whole number/integer. - If
idivided by 6 is a whole number above is true, then we print outi(you need to do this part on your own).
How should you check if a number is divisible by six? Well, you can repeat through every number
and check, does dividing it by six output a whole number?
If so, then that number is divisible by 6, and you should print it out.
In general, you should fill in the sections marked with a TODO and the bits that have a line (___)
Run
check50 daltongit/checks/c/divisible.
Ready to submit? Once you are ready, run
submit50 daltongit/checks/c/divisible.