Skip to content

Commit

Permalink
Merge pull request #16 from eddybruv/main
Browse files Browse the repository at this point in the history
description in file
  • Loading branch information
xasterKies authored Nov 1, 2021
2 parents dabdbd3 + aa6c6bd commit 5788135
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions November/Day 1/C/fizzbuzz.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @file: Write a program that console logs the nubers from 1 to n.
* But for multiples of three print "fizz" instead of the number and for the multiples of five print "buzz".
* For numbers which are multiples of both three and five print "fizzbuzz" .Make use of functions and methods where necessary.
**/

#include <stdio.h> //for I/O operations.

//prototype
void fizzBuzz(int );

int main(void){
int n;
printf("Enter number: ");
scanf("%d", &n);

fizzBuzz(n);
return 0;
}

/**
* @brief: Prints numbers from 1 to n in the form above
* @param n: stop interger.
* @return: void.
**/

void fizzBuzz(int n){
for(int i = 1; i <= n; i++){
if (i % 3 == 0 && i % 5 == 0)
printf("fizzbuzz\n");
else if (i % 3 == 0)
printf("fizz\n");
else if(i % 5 == 0)
printf("buzz\n");
else
printf("%d\n", i);
}
}

0 comments on commit 5788135

Please sign in to comment.