LamaBot, please watch your formatting. We are trying to show by example. Poorly formatted examples tells the poster it's OK to be sloppy...
Your examples are good, we just need to model good practices.
LamaBot, please watch your formatting. We are trying to show by example. Poorly formatted examples tells the poster it's OK to be sloppy...
Your examples are good, we just need to model good practices.
LamaBot, please watch your formatting. We are trying to show by example. Poorly formatted examples tells the poster it's OK to be sloppy...
Brent, two things.
#1) Your thread titles: read the rules
#2) Your formatting: please pay attention to indentation -- see this
I get it all the time
soul was missing
Why are you hijacking a 3 year old thread? Can't you start a new thread with your new problem?
"fflush(null) ;" isn't really mandatory, but lotsa ppl come back quoting problems with printf+scanf usage so...
Even more ppl come back yelling at anyone that uses it improperly like this, too. fflush(null);
will accomplish nothing at best, break your program at worst. You cannot flush the null device AFAIK. And it is only used for output, never input, streams. See this
TRY THIS OUT
goutham, around here we want the poster to find the answer. We help them with their code, we don't do their homework for them.
stringgader, read the above. In order to get this problem from your instructor, you must know something about code. This can't possibly be your first program.
by the way,, im only new to this programming thing,, tnx again
Duh, really? ;)
miniseries
I understand and believe that I have done what you said about converting by the smallest units first. My main problem is just this: " (2431.23cm = 24M, 31.23cm)."
Like my ex:
double answer1 = 0;
answer1 = (feet*12);
inches = (answer1 + inches);
meters = inches/39.37;
cout << "There are this many " << meters << " meters and centimeters." << endl;
I first multiplied the feet by inches to get the total number of inches from the feet input. I then added the number of inches entered to reach the total number of inches. I then divided inches by the number of inches in a meter to get the number of meters. And then I divided the inches by this again using the % sign to get the remaining
#
of centimeters. But according to converters I've used online my answers are always a little off. So I really can't see the problem myself. It seems like I've got it down but something actually is wrong.
Which is larger, meters or centimeters? My suggestion was convert feet/inches to inches (smallest) then convert to cm (smallest). Then it's a simple matter to get the meters. It's less exact to go the way you did.
And because your code is so huge, I'm suggesting starting over and thinking about how to make the program piece by small piece rather than all at once like you have now. A lot of what you have can …
You know, LamaBot, you don't have to quote every post in their entirety if you aren't going to reference any part of it. And you can edit the quote down to only show the relevant portions you wish to comment on. That would help by not having a 200 line quote with a 3 line reply that has little to do with the quote. Just a thought... ;)
in reincarnation deeply
She was aghast
miserly
MTV is a kiddie station.
I'm simply GR8
time for a new riddle.
What?!?! We're only allowing 3 hours for an answer? I protest!
If so, as far as I'm concerned, this thread is dead then. :sad:
I think I am making this harder than it needs to be.
Yes you are. Did you read what I posted? It would generate fairly short code. And you don't have to (and probably shouldn't in general) call a calculate function from the input function. Just work on one side of the problem first (say English to metric) then when that's running, add the other conversion.
And indent more that 1 space, please. 3-4 is standard.
And main()
is not a void, it's an int
ok maybe I didn't explain this right the array has a fixed amount of rows and columns. I am supposed to randomly populate the array with 12 objects
I wanted to identify the objects with a number such as 1. the user is then prompted to guess the location of the hidden objects.
First define your array, kinda like you did: int multi-d[rows][columns]
Then fill it with 0's with for
loops.
Then loop from 1 to 12 and use LamaBot's idea with rand()
to get a location in the array. Check if the location is zero. If so, load the loop value. If not, get another location.
Let's go back to the code in your first post -- in this thread.
#include<stdio.h>
#include <stdlib.h>
#include<conio.h> [I]//** kill this -- you shouldn't use it[/I]
#include<string.h>
#define MAXLEN 15
FILE *Entrada;
FILE *Salida;
void main() [I]//** main is NEVER a [B]void[/B], it's an [B]int[/B][/I]
{
int i,n;
char s;
char arreglopalabra[]; [I]//** you never assigned any space.
//** I assume this is for the words? Define the
//** both the max word size and max number of
//** words:
//** [B]char arreglopalabra[MAXWORDS][MAXLENGTH][/B] [/I]
char puzzle[]; /[I]/** same here[/I]
[I]//** [B]char puzzle[MAXROWS][MAXCOLS][/b][/I]
Entrada=fopen("C:\\TC\\BIN\\input.txt", "r");
Salida=fopen("C:\\TC\\BIN\\output.txt", "w");
if (Entrada==NULL || Salida==NULL)
{
printf("ERROR");
getch(); [I]//** change to [B]getchar()[/B][/I]
return;
}
else
{
while(!feof(Entrada)) [I]//** See [b] this [/b] -- and it doesn't go here anyway[/I]
{
//** read the first line (number of words
//** Loop reading that many words into [I]arreglopalabra[/I]
//** Don't you need to know the size of the puzzle?
//** Read each line of the puzzle -- in a loop
fscanf(Entrada," %d %s ", &n, &arreglopalabra, &puzzle);
fprintf(Salida, " %d %s ", n, arreglopalabra, puzzle);
}
}
clrscr(); [I]//** get rid of this, too[/I]
printf("\n %d %s", n, palabra);
getch(); [I]//** change to [B]getchar()[/B][/I]
fclose(Entrada);
fclose(Salida);
}
clrscr()
and getch()
should not be used -- they are not standard. clrscr()
hasn't been used for 10 years (about) so won't work when you get out in the real world. getch()
is not defined everywhere (only 2 current compilers) so will also cause problems in the real …
The parsing of the input is going to be the hardest thing. Initially, make the input simple. Accept 2 numbers, feet/inches or meters/centimeters.
Then combine ft/in into inches, m/cm into centimeters. Then convert to the other system and split. Switching everything to the lowest value (in/cm) makes the use of doubles easy, no splitting is really necessary (2431.23cm = 24M, 31.23cm). Simple...
does anybody know how to do this in c language? or to look for its formula? tnx alot,,
Yes, many of us know how to do this. The question is: do you? Or can you figure it out?
If you need help, asking specific questions and posting code you've tried will get excellent answers.
Close....
main() /**** main is an INT ****/
{
char option, rtn;
option = print_header();
while(option != 'q' && option != 'Q')
{
/**** display your menu ****/
/**** accept option ****/
switch(option)
{
case 'a': case 'A': /*Enter team */
printf("\nPlease Enter a new team:\n");
break;
case 'b': case'B': /*Display table*/
printf("\nLeague Table:\n");
break;
case 'c': case'C': /*Match details*/
printf("\nLeague Table:\n");
break;
case 'd': case 'D': /*Exit*/
printf("\n*** FINISHED ***\n");
exit(0);
default: /*invalid option letter entererd*/
printf("\nInvalid choice, Please try again\n");
}
option = print_header();
}
return 0;
}
In each case
, call a function to process the selection.
As he was passing a field, Sherman saw a horse in the pasture, calmly eating grass. With Reviak gaining, he decided to try to make it to the horse. But as he approached the horse, he tripped, just as a rock sailed over his head, missing by a hair's breadth.
Fate is a terrible thing to subscribe to.
His face is
fragged
Anyone that was forn would be dead... He died in 1968. (or he knows a good worm-hole)
to get where
My favorite mouse is the Logitech G5.
I use a similar optical cordless Logitech. Mine has 2 side buttons and only one under the scroller. GS model I think -- it's a few years old.
My favorite keyboard is this little beauty. The Logitech G11 gaming keyboard.
I haven't found a great keyboard since they moved the function keys to the top row. About two years ago I dusted off an old Gateway 2000 keyboard for a while until the keys started dying. I wanted to get back to the side function keys but discovered my muscle memory atrophied to the point I wasn't using the side keys... Dang it...
In the edit note, the stamp says something like "Edited 3 minutes ago at 9:15", so give us both! Just add "at [time]" after the new format. IOW, complete the change because both forms are useful.
Dani, Please consider adding "at [time]" to the posting times. I would like to know a little closer than 24 hours when a post was made.
If the time is currently 23:54 and the last post was 1 Day Ago, I would really like to know whether the post was 12:02AM (2 days) or 11:59PM (1 day). And 1 week ago is totally worthless.
I don't mind the AGO info, but I do want some detail...
I would rather people said nothing if they have nothing to say, than feel obliged to say anything.
Me too. Unfortunately... :twisted:
...what i need help with is how would i go about adding a way off adding more data
for example add a game played always one.
points either 0 for a loss, 1 for a draw or 3 for a win, goals scored and goals scored againstwant to end up with a menu system and to be able to do all the options below....so far got B and D sorted out just taking things one step at a time
****************************
* Football League *
****************************
A. Add A New Team
B. Display Current Table
C. Enter Match Details
D. Exit System
Taking one step at a time is the best way to program...
Start with the menu. Put a while
loop in main()
that
a) displays the menu
b) accept the menu selection
c) executes the appropriate function
d) exits when the EXIT selection is chosen
To add data, do you have a way to store the data for each game won? That would be the first thing. What do you have to save? What are the permissible values? Once you have that, write a function to input the information and load the data.
Since he hasn't been back since he posted this request, I guess it doesn't really matter how cool or how easy a method is. He's just wasted our time...
(sorry word wrap on makes sloppy looking code it doesn't really go on to the next line like that...........
Then stop TABbing so deeply. Use only 4 spaces, not 4 TABs
class monster{
public:
monster(){}
void initiate_enemy(int level,lvl_type ctype, int player_x, int player_y,char [50][50]);
~monster(void);
void get_pos(int & xpos, int & ypos);
void truepos(int & xpos, int & ypos);
bool move(char [50][50]);
void take_damage(int dam, int pierc);
void cast_spell();
void melee_attack(character player);
void get_stats(int & health, int & mana, int & dam, int & defence, int & pierc);
void show_stats();
bool passable(char map[50][50],direction direction);
direction facing;
bool dead;
Like that...
Wow!!! First post and you used CODE tags! Thank You. What is it you know that no other first-time poster can figure out? :mrgreen:
ok need a bit of help.
Good, that's what we're here for...
just tryin to figure a way to add scores and that from there,
Huh? What's that mean?
also the display code seems a bit messy anyway i can put it into a incremental loop?
I suppose...
The code is quite long (obviously) and you give no indication where you need changes. Maybe you need to post only the section of the code you need help with and a better explanation of exactly what you are looking for.
It would help if you would learn how to use tabs and spaces correctly so that your program is easier to read/understand. As it is few people, if anyone at all, will bother to read it. And what are lines 9 through 11 supposed to do? Must be a copy/paste error.
sorry this is my firsst c++ prgram
So are you going to format your code so we can read it?
if (month < 0 || month > 12 || day < 0 || day > 31 || year < 1900 ||| year >2099 )
fixed! :cheesy:
Somehow I doubt it... Look at the last ||
What Narue is trying to say is we can't just fill in any old line of code, we have to know what the code is supposed to accomplish, then we are able to figure out what the line is supposed to be.
In other words,
What is that line supposed to do? What makes you think a line is needed? When we know that, we can figure out what the line is.
peon
"Way down upon the Swanee River!!"
between us and
as scary as
on the subject of IM
im a student so we use it alot :) and i dont know a single person who doesnt use msn
Well, now you know at least 1 ;)
Develop a program that will determine whether a department-store customer has ex-ceeded the credit limit on a charge account.
Kool. Go for it.
If anyone could hook me up with the solution it would save me from going crazy
Oh! You want us to write it for you because you can't be bothered.... Sure, I'll get right on it. When would you like it?
[edit]And you can't be bothered to write your own post, either. You have to use someone else's -- verbatim? Sad, so sad...[/edit]
Why use Active-X? Just define a form, it's straight forward and simple.
Except, depending on the code, getchar() is not a direct replacement for getche(). Additional coding may be necessary.
Moderators can be harsh, but with kindness.
Beings from Mars are invading!