//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();
}
}