Skip to content

Commit

Permalink
Start from 1 in C implementation and remove redudant returns
Browse files Browse the repository at this point in the history
  • Loading branch information
nloveladyallen committed Nov 12, 2018
1 parent 500c7d3 commit 756de77
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions c.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include<stdio.h>
#include <stdio.h>

void fizzbuzz(int);

int main(void)
{
for (int i = 0; i <= 100; i++) {
for (int i = 1; i <= 100; i++) {
fizzbuzz(i);
}

Expand All @@ -14,7 +14,7 @@ int main(void)
void fizzbuzz(int num)
{
int printed = 0;

if (num % 3 == 0) {
printf("Fizz");
printed = 1;
Expand All @@ -23,12 +23,10 @@ void fizzbuzz(int num)
printf("Buzz");
printed = 1;
}

if (printed) {
printf("\n");
return;
} else {
printf("%d\n", num);
return;
}
}

0 comments on commit 756de77

Please sign in to comment.