suggestion

Please help!!
how to run the > symbol properly??
here's what I've done..
suggestions please...

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
while(rat>81)
   {

   y=rand()%15+10;

	switch(y)
	{
		case 10:
		{
			gotoxy(rat10=rat10++, 1);
			rat++;
			printf("10>"); break;
		}
		case 11:
		{
			gotoxy(rat11=rat11++, 2);
			rat++;
			printf("11>"); break;
		}
		case 12:
		{
			gotoxy(rat12=rat12++, 3);
			rat++;
			printf("12>"); break;
		}
		case 13:
		{
			gotoxy(rat13=rat13++, 4);
			rat++;
			printf("13>"); break;
		}
		case 14:
		{
			gotoxy(rat14=rat14++, 5);
			rat++;
			printf("14>"); break;
		}
		case 15:
		{
			gotoxy(rat15=rat15++, 6);
			rat++;
			printf("15>"); break;
		}

	}
	delay(500);
	--x;
	clrscr();
   }

	delay(1000);
	clrscr();
It is not seen what is the initial value of rat and what is the condition of the loop.
Last edited on
here what I've done..

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>

main()
{
   clrscr();
   int ratnum, cd=5, x=120, y, rat10=0, rat11=0, rat12=0, rat13=0, rat14=0, rat15=0, win;
   do
   {
    gotoxy(30,10);
    printf("Enter rat number from 1 to 15: ");
    scanf("%d", &ratnum);
   }
   while(ratnum<=9||ratnum>=16);
   clrscr();
   gotoxy(25,10);
   printf("The game will start in...");
   delay(2000);
   clrscr();
   do
   {
    gotoxy(40,10);
    printf("%d...", cd--);
    delay(1000);
    clrscr();
   }
   while(cd>0);

   //race

   while(x>200)
   {

   y=rand()%(15-10+1)+10;

	switch(y)
	{
		case 10:
		{
			rat10=rat10++;
			gotoxy(rat10, 1);
			printf("10>");break;
		}
		case 11:
		{
			rat11=rat11++;
			gotoxy(rat11, 2);
			printf("11>");break;
		}
		case 12:
		{
			rat12=rat12++;
			gotoxy(rat12, 3);
			printf("12>");break;
		}
		case 13:
		{
			rat13=rat13++;
			gotoxy(rat13, 4);
			printf("13>");break;
		}
		case 14:
		{
			rat14=rat14++;
			gotoxy(rat14, 5);
			printf("14>");break;
		}
		case 15:
		{
			rat15=rat15++;
			gotoxy(rat15, 6);
			printf("15>");break;
		}

	}
	delay(500);
	--x;
   }

	delay(1000);
	clrscr();



   getch();
   return 0;
}
¿what?

By the way, I think that rat15=rat15++; is undefined
Last edited on
@ne555
I think it is fine because in all cases, the assignment is sequenced after the value computation of the right and left operands. That would mean rat15=rat15++; is equivalent to rat15;.
1
2
3
4
5
6
#include <iostream>
int main(){
   int n=42;
   n = n++;
   std::cout << n << '\n';
}
g++ warning: operation on ‘n’ may be undefined [-Wsequence-point]
43
clang++
42

Last edited on
Specifically, "value computation" is not all that rat15++ is doing.
Topic archived. No new replies allowed.