random function

May 18, 2015 at 8:10am
is the commented part correct

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	compuer = 1+(rand() % 3);// is this part correct
		
		if (computer == 1)
		{
			com_choice = 'R';
		}
		
		else if (computer == 2)
		{
			com_choice = 'P';
		}
			
		else
		{
			com_choice = 'S';
		}
		return com_choice;
}
May 18, 2015 at 9:48am
If you want to assign 1, 2 or 3 to the compuer variable it is correct.
May 18, 2015 at 9:49am
Yes
May 18, 2015 at 9:50am
No, you mis-spelled "compuer", I'm guessing it should be "computer"?
May 18, 2015 at 9:51am
Yes lol
Topic archived. No new replies allowed.