Skip to content

Instantly share code, notes, and snippets.

@rohan1234
Created November 22, 2020 02:50
Show Gist options
  • Save rohan1234/10661996396664dc0d644190242e091b to your computer and use it in GitHub Desktop.
Save rohan1234/10661996396664dc0d644190242e091b to your computer and use it in GitHub Desktop.
FizzBuzz hackerrank solution in c++
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