Commit c2bc2ee8 authored by thomas.unsworth's avatar thomas.unsworth

first

parents
File added
#include <stdio.h>
#include <stdlib.h>
int main()
{
//setting counters to 0
int fizz = 0;
int buzz = 0;
//for loop that loops from 1 to 20
for(int i = 1; i < 21; i++){
if(i%3 == 0 && i%5 == 0){//checks the remainder is 0 for both 3 and 5
printf("FizzBuzz \n");
fizz +=1;//increasing counters
buzz +=1;
}
else if(i%3 == 0){//checks remainder for i/3
printf("Fizz \n");
fizz +=1;//increases counter
}
else if(i%5 == 0){//checks remainder for i/5
printf("Buzz \n");
buzz +=1;//increases counter
}
else{
printf("%i \n", i);//prints number
}
}
//prints counters
printf("%i \n", fizz);
printf("%i \n", buzz);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment