473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Trying to guess the value while having an exception

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 1014

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

Similar topics

6
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
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
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
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
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
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
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
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
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
by: subramanian100in | last post by:
consider the following program: #include <cstdlib> #include <iostream> using namespace std; class Test { public:
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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,...
0
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...

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.