why the result is always the same

i dont know why but the result of my program is always the same.. can someone help me?
heres the code:
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
#include<iostream.h>
#include<conio.h>
#include<time.h>
#include<dos.h>
#include<stdlib.h>
int main()
{
int a,b,c;
clrscr();
a = 5; b = 5; c = 5;
for(int x=1; x<=24; x++)
{
gotoxy(5,x);
cout << "*";
gotoxy(70,x);
cout << "*";
delay(50);
}
clrscr();
do
{
for(int x=1; x<=24; x++)
{
gotoxy(5,x);
cout << "*";
gotoxy(70,x);
cout << "*";
}
gotoxy(a,5);
cout << "A";
gotoxy(b,10);
cout << "B";
gotoxy(c,15);
cout << "C";
a = a + rand()%5+1;
b = b + rand()%5+1;
c = c + rand()%5+1;
delay(50);
}
while(a<=70 || b<=70 || c<=70);
getch();
return 0;
}

Last edited on
1) Do not use .h versions of header
2) You need to seed random number generator with unpredictable number for it to work properly. Add srand(time(0)) at the beginning of main()
i'm using turbo c .. thats why i use .h version of header..

thanks

another question why a is already greater then 70 it won't stop? it will just stop if a,b and c is greater then 70
why a is already greater then 70 it won't stop?
Your loop is written that it will stop when all a, b and c is greater than 70.
If you want to stop when at least one of the parameter is greater than 70, changee || to && in while condition.

i'm using turbo c
Stop using it. .h versions of headers became obsolete in 1998. You are 15 years behind progress. Also it has numerous bugs, lack support of numerous features. You might find that skill you will acquire using turbo c is useless with modern C++.
thanks but thats the compiler my school is using right now.. is the microsoft visual c++ the modern c++??
You can get MS visual studio express 2012 for free and it has almost full support of C++11 features.

Or you can get something like Code::Blocks + MinGW, or Orwell Dev-C++.
thanks
Topic archived. No new replies allowed.