Commit f84190b1 authored by Ollie Rhodes's avatar Ollie Rhodes

Upload New File

parent 22a87fe5
#include "stdio.h"
int main() {
printf("FizzBang Demo");
int i; //loop number
int fizzNum = 0; //number of times fizz has occurred
int bangNum = 0; //number of times bang has occurred
for (i = 1; i <= 20; i++) { //repeat 20 times
printf("\n"); //new line
if(i % 3 == 0 && i % 5 == 0){ //if multiple of 3 and 5
printf("FizzBang");
fizzNum++; //increase count of both fizzNum and bangNum
bangNum++;
} else if(i % 3 == 0){ //if multiple of 3
printf("Fizz");
fizzNum++; //increase count of fizzNum
} else if(i % 5 == 0){ //if multiple of 5
printf("Bang");
bangNum++; //increase count of bangNum
} else{ //if not either of previous two
printf("%d",i); //print the loop number
}
}
printf("\n"); //new line
printf("%d", fizzNum); //print the number of Fizz
printf("\n");
printf("%d", bangNum); //print the number of Bangs
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