void setupships()
{
int random1=10, random2=10,i;
int low=0,high=9;
int wlow=0,whigh=1;
int way;
way=rand()% (whigh - wlow + 1) + low;//0 or 1 for horizontal and vertical
  //generate two random numbers

		if(way==0)//horizontal
		{
		random1=rand() % (high - low + 1) + low;

		while(random2>5)//avoid overflow
		{
		random2=rand() % (high - low + 1) + low;
		}

		grid[random1][random2]=1;//set start position to 1

			for (i=1;i<5;i++)//rest of ship
			{
			grid[random1][random2+i]=1;
			}
		}

		if (way==1)//vertical
		{
			random2=rand() % (high - low + 1) + low;

		while(random1>5)//avoid overflow
		{
		random1=rand() % (high - low + 1) + low;
		}

		grid[random1][random2]=1;//set start position to 1

			for (i=1;i<5;i++)//rest of ship
			{
			grid[random1+i][random2]=1;
			}

		}
}