weird

what is the program was? i really did not understand it =="

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#include <iostream>
using namespace std;

int main()
{
	int number, value=0, x=2;

	cout<<"number : ";
	cin>>number;

	while (x<number && value==0)
	{
		if (number % x ==0)
			{
				value=1;
			}

		else
			{
				x=x+1;
			}
	}

	if (value==1)
		cout <<"The number is a GOOD number " << endl ;

	else
		cout <<"The number is a BAD number" <<endl;

system("PAUSE");
return 0;
}
== is the test for equality.
if (value==1) means "if value is equal to 1"

What is the program doing? Well, it uses the terms good and bad which are arbitrary labels. However, this looks like a common algorithm which crops up very frequently on these forums.
closed account (18hRX9L8)
a==b returns true if a is exactly b and false if a is not exactly b.
a=b assigns the value of a to the value of b.

If you state your problems/questions/comments properly, we can help you.
Last edited on
I would have said
a=b assigns the value of b to the variable a.

(assigning a value to another value doesn't make any sense, for example assigning 5 to 3 is not possible).
Last edited on
Topic archived. No new replies allowed.