Buzz Fizz

Description:

Write a program in C which prints the numbers from 1 to 100. But, multiples of 3 should be replaced with "Fizz", multiples of 5 should be replaced with "Buzz" and multiples of both 3 and 5 should be replaced with "FizzBuzz" Test Case 1 Input (stdin) 3 Expected Output 1 2 Fizz Test Case 2 Input (stdin) 10 Expected Output 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz

Program :

#include <iostream>

using namespace std;

int main()

{

int n,i;

  char c[50];

  cin>>n;

  for(i=1;i<n+1;i++)

  {

    if(i%3==0 && i%5==0)

      cout<<"FizzBuzz\n";

    else if(i%3==0)

      cout<<"Fizz\n";

    else if(i%5==0)

      cout<<"Buzz\n";

    else

      cout<<i<<"\n";

  }

return 0;

}