Hey! I need help. Im new to programming. So how the codings will like to be ?
write a program to accept an integer number from the user and display the message '" the number is divisible by both 3 and 5" or "the number is NOT divisible by both 3 and 5" according to the input value
Hi Epeeist, Welcome to C++! This code will handle your problem, but to understand what's going on study the tutorials, buy a book, or listen to a good instructor. As Vlad said, start off with something simple. Cheers, Don.
#include <iostream>
usingnamespace std;
int main ()
{
cout <<"To check whether a number is divisible by both 3 and 5. \n\n";
int i;
while (i!=0)
{
cout <<"Please enter a number: ";
cin>> i;
cin.get();
if (i%15 ==0 && i !=0 )
cout <<"\nThe number "<<i<<" is divisible by both 3 and 5.\n";
else
cout<<"\nThe number "<<i<<" is NOT divisible by both 3 and 5.\n";
cin.get();
}
return 0;
}