LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-01-2010, 12:40 AM   #1
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Rep: Reputation: 2
Post 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);
}
 
Old 11-01-2010, 12:44 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Maybe try initializing "total" to 0?

Just a thought
 
Old 11-02-2010, 01:32 AM   #3
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Original Poster
Rep: Reputation: 2
I will give a try tomorrow. I will report back if possible.

I tried the changes you proposed but they did not work.

Last edited by darkstarbyte; 11-03-2010 at 08:58 PM.
 
Old 11-07-2010, 11:16 AM   #4
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Original Poster
Rep: Reputation: 2
Post 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);
}
 
Old 11-07-2010, 01:11 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 11-07-2010, 08:36 PM   #6
John VV
Guru
 
Registered: Aug 2005
Posts: 12,834

Rep: Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709
it almost looks like homework???
 
Old 11-08-2010, 06:04 PM   #7
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Linux mint, Slackware
Posts: 231

Original Poster
Rep: Reputation: 2
/* 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.
 
Old 11-08-2010, 09:19 PM   #8
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 808

Rep: Reputation: 178Reputation: 178
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."
 
Old 11-08-2010, 10:42 PM   #9
John VV
Guru
 
Registered: Aug 2005
Posts: 12,834

Rep: Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709Reputation: 1709
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 .
 
  


Reply

Tags
error, gcc, programing


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
make gcc to report prototype errors nuliknol Programming 2 09-06-2010 05:30 PM
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) compilation error adhesh_19 Red Hat 0 01-05-2010 05:34 AM
LXer: Report: At Intel's Request, Glide Online Suite To Get Linux Client, Back End LXer Syndicated Linux News 0 10-17-2006 12:54 AM
How can I report the Error Report? domeili Linux - Newbie 1 10-30-2003 05:42 AM


All times are GMT -5. The time now is 03:13 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration