Created
November 22, 2020 02:50
-
-
Save rohan1234/10661996396664dc0d644190242e091b to your computer and use it in GitHub Desktop.
FizzBuzz hackerrank solution in c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void fizzBuzz(int n) { | |
int i; | |
i=n; | |
for(int i=1;i<=n;i++) | |
{ | |
if(i%3==0 && i%5==0) | |
{ | |
cout<<"FizzBuzz"<<endl; | |
} | |
else if(i%3==0 && (!i%5==0)) | |
{ | |
cout<<"Fizz"<<endl; | |
} | |
else if(i%5==0 && !(i%3==0)) | |
{ | |
cout<<"Buzz"<<endl; | |
} | |
else if(!(i%3==0 && i%5==0)) | |
{ | |
cout<<i<<endl; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment