expression?

I have to enter a correct expression for (true), would 5 mod 2 work? I'm not really sure how to do this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	{
		int i;  // to store input from the user

		cout << "Enter an integer to test divisibility: ";
		cin >> i;

		if (true)
			cout << "+++ The integer you entered is either divisible by 2 and"
			" 3, or divisible by 5\n"
			<< "and 7, or both.\n";
		else
			cout << "--- The integer you entered is not divisible by 2 and 3,"
			" or by 5 and 7, or\n"
			<< "both.\n";
	}

	cout << "\n-----------------------------------------"
		<< "--------------------------------------\n\n";
Last edited on
You can represend your condition as:
(integer is divisible by 2) and (integer is divisible by 3) or (integer is divisible by 5)
integer → i
is divisible by x → % x == 0
↓↓↓↓↓↓↓↓↓
((i % 2 == 0) and (i % 3 == 0)) or (i % 5 == 0)
↓↓↓↓↓
if ( ((i % 2 == 0) and (i % 3 == 0)) or (i % 5 == 0) )
thanks
Topic archived. No new replies allowed.