ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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);
}
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);
}
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.
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
NO ERROR ( and runs just fine )
if this c was saved as test.cpp ( c++)
this error ( gcc 4.1)
Code:
gcc -o test test.cpp
/tmp/ccWq2Ej2.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
SO with out KNOWING just WHAT YOU DID
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 .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.