Please test the code [racing game]

Is the code is running properly ?

//header
#include <stdio.h>
//for printf(); & scanf(); function
#include <conio.h>
//for clrscr(); function
#include <dos.h>
//for delay function
#include <stdlib.h>
//for random function

//main program
main()
{
clrscr();//to clear the screen
int ratnum, cd=5, x=120, y, rat1=0, rat2=0, rat3=0, rat4=0, rat5=0, rat6=0, rat7=0, rat8=0, rat9=0, rat10=0, rat11=0, rat12=0, rat13=0, rat14=0, rat15=0, win;//inputs
do //do the following commands
{
gotoxy(30,10);//to put the printed value anywhere.
printf("Enter rat number from 1 to 15: ");//to print the value
scanf("%d", &ratnum);//to enter a value
}
while(ratnum<=0||ratnum>=16);//checking, if true return to do and if false go down.
clrscr();
gotoxy(25,10);
printf("The game will start in...");
delay(2000);//to pause the printed value.
clrscr();
do
{
gotoxy(40,10);
printf("%d...", cd--);
delay(1000);
clrscr();
}
while(cd>0);

//race

while(x>0)
{

switch(ratnum)//switch command
{
case 15:
{
y=random(2);//to make the y=between the 2 numbers
gotoxy(rat15+y, 1);//to place the > in the x axis while adding 2 or 1. and to place in the y axis in 1
rat15+=y;//to make the y equal to rat15
printf(">");
}
case 14:
{
y=random(2);
gotoxy(rat14+y, 2);
rat14+=y;
printf(">");
}
case 13:
{
y=random(2);
gotoxy(rat13+y, 3);
rat13+=y;
printf(">");
}
case 12:
{
y=random(2);
gotoxy(rat12+y, 4);
rat12+=y;
printf(">");
}
case 11:
{
y=random(2);
gotoxy(rat11+y, 5);
rat11+=y;
printf(">");
}
case 10:
{
y=random(2);
gotoxy(rat10+y, 6); rat10+=y; printf(">");
}
case 9:
{
y=random(2);
gotoxy(rat9+y, 7); rat9+=y; printf(">");
}
case 8:
{
y=random(2);
gotoxy(rat8+y, 8); rat8+=y; printf(">");
}
case 7:
{
y=random(2);
gotoxy(rat7+y, 9); rat7+=y; printf(">");
}
case 6:
{
y=random(2);
gotoxy(rat6+y, 10); rat6+=y; printf(">");
}
case 5:
{
y=random(2);
gotoxy(rat5+y, 11); rat5+=y; printf(">");
}
case 4:
{
y=random(2);
gotoxy(rat4+y, 12); rat4+=y; printf(">");
}
case 3:
{
y=random(2);
gotoxy(rat3+y, 13); rat3+=y; printf(">");
}
case 2:
{
y=random(2);
gotoxy(rat2+y, 14); rat2+=y; printf(">");
}
case 1:
{
y=random(2);
gotoxy(rat1+y, 15); rat1+=y; printf(">");
}
delay(random (500));
--x;
clrscr();
}
}

delay(1000);
clrscr();

if(rat1>rat2&&rat1>rat3&&rat1>rat4&&rat1>rat5&&rat1>rat6&&rat1>rat7&&rat1>rat8&&rat1>rat9&&rat1>rat10&&rat1>rat11&&rat1>rat12&&rat1>rat13&&rat1>rat14&&rat1>rat15)
win=1;
else
if(rat2>rat3&&rat2>rat4&&rat2>rat5&&rat2>rat6&&rat2>rat7&&rat2>rat8&&rat2>rat9&&rat2>rat10&&rat2>rat11&&rat2>rat12&&rat2>rat13&&rat2>rat14&&rat2>rat15)
win=2;
else
if(rat3>rat4&&rat3>rat5&&rat3>rat6&&rat3>rat7&&rat3>rat8&&rat3>rat9&&rat3>rat10&&rat3>rat11&&rat3>rat12&&rat3>rat13&&rat3>rat14&&rat3>rat15)
win=3;
else
if(rat4>rat5&&rat4>rat6&&rat4>rat7&&rat4>rat8&&rat4>rat9&&rat4>rat10&&rat4>rat11&&rat4>rat12&&rat4>rat13&&rat4>rat14&&rat4>rat15)
win=4;
else
if(rat5>rat6&&rat5>rat7&&rat5>rat8&&rat5>rat9&&rat5>rat10&&rat5>rat11&&rat5>rat12&&rat5>rat13&&rat5>rat14&&rat5>rat15)
win=5;
else
if(rat6>rat7&&rat6>rat8&&rat6>rat9&&rat6>rat10&&rat6>rat11&&rat6>rat12&&rat6>rat13&&rat6>rat14&&rat6>rat15)
win=6;
else
if(rat7>rat8&&rat7>rat9&&rat7>rat10&&rat7>rat11&&rat7>rat12&&rat7>rat13&&rat7>rat14&&rat7>rat15)
win=7;
else
if(rat8>rat9&&rat8>rat10&&rat8>rat11&&rat8>rat12&&rat8>rat13&&rat8>rat14&&rat8>rat15)
win=8;
else
if(rat9>rat10&&rat9>rat11&&rat9>rat12&&rat9>rat13&&rat9>rat14&&rat9>rat15)
win=9;
else
if(rat10>rat11&&rat10>rat12&&rat10>rat13&&rat10>rat14&&rat10>rat15)
win=10;
else
if(rat11>rat12&&rat11>rat13&&rat11>rat14&&rat11>rat15)
win=11;
else
if(rat12>rat13&&rat12>rat14&&rat12>rat15)
win=12;
else
if(rat13>rat14&&rat13>rat15)
win=13;
else
if(rat14>rat15)
win=14;
else
win=15;
gotoxy(20,10);
printf("Congratulations!! The winner is rat%d", win);


getch();
return 0; //exit
}
Topic archived. No new replies allowed.