guys, I want to make a program that will do the following:
1. the user should set the value of his own ship
2.The user should guess the random value of the enemy AI, if guessed correctly, the AI ships will be destroyed displaying the remaining ship of the enemy AI
3. Also the AI will try to guess the users ships, if guessed correctly, the user's ship will be destroyed displaying the remaining ships of the user
4. When the user/AI enter his own ship number, he'll lose his ship in return
5. The program will not stop unless the AI ships aren't destroyed completely
6. Also the AI can win if it guessed all the user's ships
My code works but I can't just make it do the way I want it to do.This is my code:
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
int main(void)
{
clrscr();
int a,c,b,d;
randomize();
int z=random(10),y=random(10),x=random(10);
printf("ship 1");
scanf("%d",&b);
printf("ship 2");
scanf("%d",&c);
printf("ship 3");
scanf("%d",&d);
if(a==b||c||d)
{
while(a!=z&&a!=y&&a!=x)
{
printf("ENTER 1: ");
scanf("%d",&a);
printf("TRY AGAIN\n");
}}
else
{
}
printf("GREAT!");
getch();
return 0;
}
I use turbo C++ to make this. Any Suggestion to improve my program.