void fizzBuzz(int n) {
for (int i = 0; i < n; i++){
if (i % 3 == 0 && i % 5 == 0){
printf("FizzBuzz\n");}
else if (i % 3 == 0 && i % 5 != 0){
printf("Fizz\n");}
else if (i % 3 != 0 && i % 5 == 0){
printf("Buzz\n");}
else
printf("%d", i);}
}
int main() {
int n;
scanf("%d", &n);
print_all(n);
return 0;
}
I want to use the fizzbuzz function in my main function. how do I call void Fizzbuzz(int n) function and have it accept user input as shown?
How to
Just call it by its name and pass the parameters needed. like this:
Here you are calling the function
fizzBuzzand passing it a parameter of type integer which value is 6. If you want to do it with variables is the same way, just pass the variable (of type integer) as the parameter of the function. Like this:You would obtain the same output.
Inside your main function would be: