is my code right

Write a program that reports whether a number input is divisible by
7. (Hint: If a number is divisible by 7, that means you can divide it by 7 and get a remainder of 0.)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;

int main() {

	int n;
	cout << "Enter the number you wish to divide by 7";
	cin >> n;
	if ( n % 7 == 0 ) 
	cout << " The number is divisible by 7.";
	else 
	cout << " The number is not divisible by 7.";

	return 0;
	}
I don't know, what does your compiler say? If it compiles, is it always correct?

http://ideone.com/9NRHoo
Topic archived. No new replies allowed.