This might be a gcc linux client error report.
#include <stdio.h>
#define speedlimit 55 #define rate 15 #define first_ticket 85 #define second_ticket 95 #define third_ticket 100 int main() { int total,fine,speeding; puts("Speeding Tickets\n"); /* first ticket */ speeding = first_ticket - speedlimit; /* mph over the speed limit */ fine = speeding * rate; total = total + fine; printf("For going %d in a %d zone: $%d\n",first_ticket,speedlimit,fine); /* second ticket */ speeding = second_ticket - speedlimit; fine = speeding * rate; total = total + fine; printf("For going %d in a %d zone: $%d\n",second_ticket,speedlimit,fine); /* third ticket */ speeding = third_ticket - speedlimit; fine = speeding * rate; total = total + fine; printf("For going %d in a %d zone: $%d\n",third_ticket,speedlimit,fine); /* This is where things get messy my total is all over the place */ /* Display total */ printf("\nTotal in fines: $%d\n",total); return(0); } |
Maybe try initializing "total" to 0?
Just a thought :) |
I will give a try tomorrow. I will report back if possible.
I tried the changes you proposed but they did not work. |
Error-ed code or compiler
more compiled odd code
#include <stdio.h> #define distance 378921.46 #define speed 140 int main() { float duration,days; duration = distance / speed; days = duration / 24; printf("The moon is %f km away.\n",distance); printf("Traveling at %f kph, ",speed); printf("it would take %f hours to drive to the moon.\n",days); printf("That's %f days.\n",days); return(0); } |
You've posted 2 pices of source code (none in [Code ] tags), but haven't said anything about them. Is there a question here?
--- rod. |
it almost looks like homework???
|
/* Sorry I thought I did say what was wrong. */
So when I compiled the code my answer on some of them are all over the place. On the first code it was the variable that was total and the second one the same except it was not called total. |
Homework assignments such as this one were made obsolete when Einstein came along.
A cop pulls over a physicist, see, and says: "Do you have any idea how fast you were going?" And the physicist, of course, says, "No, but I know exactly where I was." |
IF you posted the error ...
That would have been VERY helpful ALSO just HOW you ware trying to build it -- the full build line and the FULL error-- for example the FIRST post ( saved as "test.c" using gcc 4.1 ) Code:
gcc -o test test.c if this c was saved as test.cpp ( c++) this error ( gcc 4.1) Code:
gcc -o test test.cpp we can NOT HELP !!! We DO NOT KNOW how you tried to build it !!! and yes this dose look like something from a text book . |
All times are GMT -5. The time now is 07:08 AM. |