In C Code a program that will print the numbers from 1 to 1
(In C++ ) Code a program that will print the numbers from 1 to 15, however when the number is a multiple of 3 it will print \"Whiz\". If the number is a multiple of 5, print \"Bang.\" If the number is a multiple of 3 and 5 print \"Whiz Bang\"
Solution
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
for(int i=1;i<=15;i++)
{
if(i%3==0&&i%5==0) //for number both divisible by both 5 and 3.
{
cout<<\"Whiz Bang\"<<endl;
break;
}
if(i%3==0) { //for number disible by 3.
cout<<\"whiz\"<<endl;
}
if(i%5==0){ //for number disible by 3.
cout<<\"Bang\"<<endl;
}
if(i%3!=0&&i%5!=0) //for number not divisible by 5 or 3.
{
cout<<i<<endl;
}
}
getch();
}
// If the Answer was satisfying feedback is appreciated, & do comment if not correct or not as u expected.. thanx..
