473,503 Members | 338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to guess the value while having an exception

4 New Member
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.
Feb 27 '15 #1
0 1017

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2322
by: Daniel Wilson | last post by:
I am having exception-handling and stability problems with .NET. I will have a block of managed code inside try...catch and will still get a generic ..NET exception box that will tell me which...
7
3298
by: | last post by:
I fail to understand why that the memory allocated in the void create(int **matrix) does not remain. I passed the address of matrix so shouldn't it still have the allocated memory when it returns...
3
7830
by: Lekyan | last post by:
I have problem setting the password for an ADAM user using C#. I used the SetPassword code given in the Microsoft page, changed several parameters, but ran into an exception. I wonder if other...
4
1428
by: Frank Rizzo | last post by:
Hello. Every now and then (it's rare), i get an exception when calling SqlDataAdapter.Fill. The code is calling a stored procedure and attempts to stuff the results into a dataset. It yields the...
6
1571
by: Ant | last post by:
Hi, I'd like to catch a specific exception that is raised when an int is assigned a string. I can't force the exception to see what is thrown because it creates a compile time error when fed a...
6
249
by: Shane.H.1 | last post by:
Hi Im learning C sharp, and I am trying to grok exceptions Using the following code name is returning "N/A" where I want it to return the string held by tempHold What am I doing wrong? public...
1
1901
by: Zytan | last post by:
http://msdn2.microsoft.com/en-us/library/system.exception.data(VS.80).aspx says: "Avoid key conflicts by adopting a naming convention to generate unique keys for key/value pairs. ... two...
3
2134
by: Sami | last post by:
Hello, I am new to Python. I tried to hook my own ExceptionPrintingFunction sys.excepthook but it does not work. This is what I wrote:...
17
2728
by: Cramer | last post by:
I plan to implement an exception logging feature in an ASP.NET Web application that writes encountered exceptions to disk. The exception data will be stored as XML. I am planning on having each...
1
1374
by: subramanian100in | last post by:
consider the following program: #include <cstdlib> #include <iostream> using namespace std; class Test { public:
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.