back for help

Hello,
I posted about a week ago with some pretty n00b syntax errors, now i'm tring to write a program to display the prime numbers between 1 and 100. I can write 1-100 to the screen with the for loop but I'm having some trouble figuring out the if statements. Here is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//a prime number is only divisible by itself
#include <iostream>
using namespace std;

int main()
{
//define variables used
	int x;
	bool a;

	for(x=1;x<=100;x++){
	if((x%2 == 0) || (x%3 == 0) || (x%5 == 0) || (x%7 == 0) || (x%9 == 0)){a=true;}
	
	if(a != true){a=false;}
	
	if(a == false){cout << "\n" << x << " is prime.";}
	}

	return 0;
}
OHH THE P0NAGE, y'all don't even know. i've been on this since last night (so not that long) but OHH tHE P0NAGE. just wanna say w00t, l33t, and lawlz. THANKYA all for readin this, and HERE'S MA CODE:
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()
{
	int x, y;

	for(x=1;x<=100;x++){
	if(x == 2)
	cout << x << " is prime.\n";
	if(x == 3)
	cout << x << " is prime.\n";
	if(x == 5)
	cout << x << " is prime.\n";
	if(x == 7)
	cout << x << " is prime.\n";
	if(!(x%2 == 0) && !(x%3 == 0) && !(x%5 == 0) && !(x%7 == 0) && !(x%9 == 0))
	cout << x << " is prime.\n";
	}

	return 0;
}
Topic archived. No new replies allowed.