BuzzFizz Program in C++


Prev Tutorial Next Tutorial

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
buzz fizz program in c++
Prev Tutorial Next Tutorial

Advertisements




Download Projects

Advertisements

FREE Online Google Play APK Downloader

Buy APP Installs, Buy 100% Genuine Installs