BuzzFizz Program in C++
Buzz Fizz Program in C++
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"?.
Buzz Fizz Program in C
#include<iostream.h>
#include<conio.h>
void main()
{
int no, i;
clrscr();
cout<<"Enter Range of numbers: ";
cin>>"%d",&no;
for(i=1; i<=no; i++)
{
if((i % (3*5)) == 0)
{
cout<<"FizzBuzz\n";
}
else if ((i % 5) == 0)
{
cout<<"Buzz\n";
}
else if ((i % 3) == 0)
{
cout<<"Fizz\n";
}
else
{
cout<<"%d\n",i;
}
}
getch();
}
Output
Enter Range of number: 20 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz
Advertisements