Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 8th, 2005, 10:35 AM   #1
h2311
Newbie
 
Join Date: Apr 2005
Posts: 2
Rep Power: 0 h2311 is on a distinguished road
Exclamation a new member favoring a help

hi guys, im a new member here. i hope i can find a solution for my problem.
i have been assigned a project in C language that requires us to build a non-scientific calculator. The user should give the instructions as a sequence ending with sentinel “=” and the program should calculate the result without considering the precedence of the operators. the sequence can be any length. The operators that must be used are:
+ (addition), - (subtraction), * (multiplication), / (division), ^ (power)

my problem is that i could not make the program calculate the results.... i enter the sequence ending with the sentinel '=' but the calculations are not done...
i will be so glad if anyone can helpppp
thanks
h2311 is offline   Reply With Quote
Old Apr 8th, 2005, 12:39 PM   #2
brkstf
Programmer
 
brkstf's Avatar
 
Join Date: Feb 2005
Posts: 89
Rep Power: 4 brkstf is on a distinguished road
you get a lot more help if you post some code that you have worked on.

my c is rusty, but in c++, this is really easy. cin>> an int, then a char, then another int.

use the character (+-*/^) as an argument to a doMath kinda function, and ints 1 and 2 as operands. in c++, a simple version (without bad input catching) can be written in about 10-15 lines of code. should be about the same in c. i'm just trying to remember how the get and getch work. i'm really out of practice.
brkstf is offline   Reply With Quote
Old Apr 8th, 2005, 1:55 PM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
lets see what you have done so far...
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Apr 8th, 2005, 7:48 PM   #4
Encryption
Programmer
 
Encryption's Avatar
 
Join Date: Feb 2005
Posts: 42
Rep Power: 0 Encryption is on a distinguished road
Send a message via AIM to Encryption Send a message via MSN to Encryption Send a message via Yahoo to Encryption
Show your code, and then, if you haven't already done so, learn arrays and vectors pretty well.(Vectors may not be necesarry).
__________________
Quote:
Originally Posted by Bjarne Stroustrup
* "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do succeed, you will blow away your whole leg."

* "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone."
Encryption is offline   Reply With Quote
Old Apr 8th, 2005, 8:23 PM   #5
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I was thinking just get it as one long String. Use the +-/*^ characters to split the string into 4 ways, first integer, operator, 2nd integer an equal sign, and then use an atoi() function to get the ints you want, then just do the proper calculations. It sounds like you can basically disregard the equal sign and almost consider it always there. Of course, like others have said, I don't know exactly how far you've gotten since you haven't posted any of your code. Also, I could be making this harder than it is.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Apr 8th, 2005, 8:50 PM   #6
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 555
Rep Power: 5 Benoit is on a distinguished road
Welcome to the forums dude

Simple program...Post the code you have so far and we'll help you out
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Old Apr 9th, 2005, 12:32 AM   #7
anandt4u
Newbie
 
Join Date: Feb 2005
Posts: 22
Rep Power: 0 anandt4u is on a distinguished road
Quote:
Originally Posted by Encryption
Show your code, and then, if you haven't already done so, learn arrays and vectors pretty well.(Vectors may not be necesarry).
are vectors available in C?? i thought it was java and C# feature..can someone enlighten me about that
anandt4u is offline   Reply With Quote
Old Apr 9th, 2005, 12:36 AM   #8
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
They are in C++, not in C. (You could program them yourself in C without too much trouble)
uman is offline   Reply With Quote
Old Apr 9th, 2005, 12:46 AM   #9
anandt4u
Newbie
 
Join Date: Feb 2005
Posts: 22
Rep Power: 0 anandt4u is on a distinguished road
Quote:
Originally Posted by uman
They are in C++, not in C. (You could program them yourself in C without too much trouble)
can you tell me how to use vectors in gcc...tx
anandt4u is offline   Reply With Quote
Old Apr 9th, 2005, 4:58 AM   #10
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Quote:
can you tell me how to use vectors in gcc...tx
Well by looking for a nice third party vector thingummawat. You probably don't want to write your own if you're asking how to use them in a compiler.
Cerulean is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:48 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC