programming

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
At first try to write yorself at least function main with an empty body.:)
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.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace 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;
}
Topic archived. No new replies allowed.