473,785 Members | 3,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

algebraic expression 'a*b+c' with CIN .Is it possible?

algebraic expression 'a*b+c' with CIN .Is it possible?

How to transfer the algebraic expression 'a*b+c' to the variable s
(all double) with cout in a "Console Application" ?

cout<<"Input a,b,c and expression in a,b,c "<<endl;
cin>>a;
cin>>b;
cin>>c;

cin>???!!!! and here !!!???. If I do cin>>(a*b*c) it's wrong !!!!
cout<<"This is a*b+c \n"<< s <<endl;

How to do it ?

Thanks
cristian
Aug 22 '07 #1
9 3758
Cristian wrote:
algebraic expression 'a*b+c' with CIN .Is it possible?

How to transfer the algebraic expression 'a*b+c' to the variable s
(all double) with cout in a "Console Application" ?

cout<<"Input a,b,c and expression in a,b,c "<<endl;
cin>>a;
cin>>b;
cin>>c;

cin>???!!!! and here !!!???. If I do cin>>(a*b*c) it's wrong !!!!
cout<<"This is a*b+c \n"<< s <<endl;

How to do it ?
Read a string using 'std::getline'. If you need to calculate the
result of that expression, you'll need to implement an expression
parser. See chapter 6 of TC++PL.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 22 '07 #2
On Wed, 22 Aug 2007 11:21:39 -0400, "Victor Bazarov"
<v.********@com Acast.netwrote:
>Cristian wrote:
>algebraic expression 'a*b+c' with CIN .Is it possible?

How to transfer the algebraic expression 'a*b+c' to the variable s
(all double) with cout in a "Console Application" ?
]zuip[
>Read a string using 'std::getline'. If you need to calculate the
result of that expression, you'll need to implement an expression
parser. See chapter 6 of TC++PL.

V
Is there something already prepared ?
Chapter 6 is very very crypticccccsss! !!!.....for me..
Heartfelt thankyou
Aug 22 '07 #3
On 2007-08-22 17:32, Cristian wrote:
On Wed, 22 Aug 2007 11:21:39 -0400, "Victor Bazarov"
<v.********@com Acast.netwrote:
>>Cristian wrote:
>>algebraic expression 'a*b+c' with CIN .Is it possible?

How to transfer the algebraic expression 'a*b+c' to the variable s
(all double) with cout in a "Console Application" ?
]zuip[
>>Read a string using 'std::getline'. If you need to calculate the
result of that expression, you'll need to implement an expression
parser. See chapter 6 of TC++PL.

V

Is there something already prepared ?
Chapter 6 is very very crypticccccsss! !!!.....for me..
Yes, the code is in there, but if you really want to use it you really
should take the time to understand it also.

--
Erik Wikström
Aug 22 '07 #4
>
Is there something already prepared ?
Chapter 6 is very very crypticccccsss! !!!.....for me..
Maybe you should start learing C++ before you do the hard stuff?
Aug 23 '07 #5
Cristian wrote:
algebraic expression 'a*b+c' with CIN .Is it possible?

How to transfer the algebraic expression 'a*b+c' to the variable s
(all double) with cout in a "Console Application" ?

cout<<"Input a,b,c and expression in a,b,c "<<endl;
cin>>a;
cin>>b;
cin>>c;

cin>???!!!! and here !!!???. If I do cin>>(a*b*c) it's wrong !!!!
cout<<"This is a*b+c \n"<< s <<endl;

How to do it ?
Let me guess: What you want is for the program to parse and interpret
a user-inputted mathematical expression such as for example "a*b+c" (or
any other expression thereof) for given value of the variables?

There's no language feature in C++ itself which would allow this.
C++ is a compiled language, it's not an interpreted scripting language.
What you want to do is easy to do in scripted languages because the
script interpreter is basically parsing and interpreting the input
source code all the time. Thus it's trivial to construct an expression
(eg. by asking the user for it) and make the interpreter parse and
interpret it. However, C++ is not an interpreted language and thus this
kind of thing is not possible directly.

If you want to be able to parse and interpret mathematical expressions
entered by the user you need a parsing/interpreting library for that.
Here's one example of such library: http://iki.fi/warp/FunctionParser/
Aug 23 '07 #6
On Thu, 23 Aug 2007 16:42:19 +0300, Juha Nieminen
<no****@thanks. invalidwrote:
>Cristian wrote:
>algebraic expression 'a*b+c' with CIN .Is it possible?
]zac..cc[
There's no language feature in C++ itself which would allow this.
C++ is a compiled language, it's not an interpreted scripting language.
What you want to do is easy to do in scripted languages because the
script interpreter is basically parsing and interpreting the input
source code all the time. Thus it's trivial to construct an expression
(eg. by asking the user for it) and make the interpreter parse and
interpret it. However, C++ is not an interpreted language and thus this
kind of thing is not possible directly.
ok but I don't understand why there isn't a library for this (for ex
in STD). I intend say: ask for algebraic input( mathematical
expressions ex. function) isn't common ?
In a scientific program I believe that this ownership is obligatory,
if there is not this tool as it can make the consumer to interact
with the program and to introduce a mathematical function whose
structure cannot be anticipated in phase of compilation?
>
If you want to be able to parse and interpret mathematical expressions
entered by the user you need a parsing/interpreting library for that.
Here's one example of such library: http://iki.fi/warp/FunctionParser/
I have to now develop small forms to personal use but it is probable
that in the future can use them for a greater project and therefore
before wasting time I would like to know if this your parser is
possible to also purchase commercial license and how much coast

I apologize you for my bad English
Tanks
cristian
Aug 23 '07 #7
Cristian wrote:
On Thu, 23 Aug 2007 16:42:19 +0300, Juha Nieminen
<no****@thanks. invalidwrote:
>Cristian wrote:
>>algebraic expression 'a*b+c' with CIN .Is it possible?
]zac..cc[
> There's no language feature in C++ itself which would allow this.
C++ is a compiled language, it's not an interpreted scripting
language. What you want to do is easy to do in scripted languages
because the script interpreter is basically parsing and interpreting
the input source code all the time. Thus it's trivial to construct
an expression (eg. by asking the user for it) and make the
interpreter parse and interpret it. However, C++ is not an
interpreted language and thus this kind of thing is not possible
directly.
ok but I don't understand why there isn't a library for this (for ex
in STD). I intend say: ask for algebraic input( mathematical
expressions ex. function) isn't common ?
In a scientific program I believe that this ownership is obligatory,
if there is not this tool as it can make the consumer to interact
with the program and to introduce a mathematical function whose
structure cannot be anticipated in phase of compilation?
If that's a requirement, and the entier system is written in C++,
then _usually_ folks /embed/ an interpreter from some other, well
known or popular language, like Python, or Basic, or Perl. Most
of them are /embeddable/. But please don't ask us where to find
such an interpreter or how to embed it. Such activity is beyond
the subject matter of this newsgroup.
> If you want to be able to parse and interpret mathematical
expressions entered by the user you need a parsing/interpreting
library for that. Here's one example of such library:
http://iki.fi/warp/FunctionParser/

I have to now develop small forms to personal use but it is probable
that in the future can use them for a greater project and therefore
before wasting time I would like to know if this your parser is
possible to also purchase commercial license and how much coast
www.google.com

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 23 '07 #8
On Thu, 23 Aug 2007 12:38:51 -0400, "Victor Bazarov"
<v.********@com Acast.netwrote:
>Cristian wrote:
>On Thu, 23 Aug 2007 16:42:19 +0300, Juha Nieminen
<no****@thanks .invalidwrote:
>>Cristian wrote:
algebraic expression 'a*b+c' with CIN .Is it possible?
]zac..cc[
>> There's no language feature in C++ itself which would allow this.
C++ is a compiled language, it's not an interpreted scripting
language. What you want to do is easy to do in scripted languages
because the script in
]zac[
>such an interpreter or how to embed it. Such activity is beyond
the subject matter of this newsgroup.
doesn't this group speak of c++? have not I perhaps said since the
beginning that I am a beginner? I have told him.
but it is not able not answer in this group ?. To use some faculty not
to answer is a right. Use it
And however if I have disturbed I ask excuse everybody
thanks
cristian

Aug 23 '07 #9
Cristian wrote:
On Thu, 23 Aug 2007 12:38:51 -0400, "Victor Bazarov"
<v.********@com Acast.netwrote:
>Cristian wrote:
>>On Thu, 23 Aug 2007 16:42:19 +0300, Juha Nieminen
<no****@thank s.invalidwrote:

Cristian wrote:
algebraic expression 'a*b+c' with CIN .Is it possible?
>
]zac..cc[
There's no language feature in C++ itself which would allow this.
C++ is a compiled language, it's not an interpreted scripting
language. What you want to do is easy to do in scripted languages
because the script in
]zac[
>such an interpreter or how to embed it. Such activity is beyond
the subject matter of this newsgroup.

doesn't this group speak of c++?
Yes, it does. You need to separate the language itself with its
applications, though. Example: there is this newsgroup, called
'alt.usage.engl ish' where I can learn how to use English, but they
will not tell me how to write a good business proposal in English.
Writing good business proposals is not necessarily the topic of
'alt.usage.engl ish'.

Same here. If you have a language problem, we're happy to help
you with it. However, we will not tell you how to develop some
algorithm using C++. That's beyond this newsgroup's topic.
have not I perhaps said since the
beginning that I am a beginner?
Being a beginner is not an excuse.
I have told him.
but it is not able not answer in this group ?.
We are not able to tell you what you need to do to use a Python
interpreter in a C++ program. It's a topic for a Python forum.
To use some faculty not
to answer is a right.
I am not sure I understand that statement.
Use it
And however if I have disturbed I ask excuse everybody
You have not disturbed anybody, I hope. And from what I can see,
you have received at least some advice you should be able to use.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 23 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
3235
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since there are no assignment expressions in Python, I have to use a temp var. That's a little more messy, but bearable:
6
2775
by: DennisNedry | last post by:
Any general ideas on techniques for creating parsers for algebraic and linear equations?
18
1540
by: talin at acm dot org | last post by:
I've been reading about how "lambda" is going away in Python 3000 (or at least, that's the stated intent), and while I agree for the most part with the reasoning, at the same time I'd be sad to see the notion of "anonymous functions" go - partly because I use them all the time. Of course, one can always create a named function. But there are a lot of cases, such as multimethods / generics and other scenarios where functions are treated...
28
16423
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to write a safe but easy implementation (i.e. no codedom) for an IBindingListView.Filter (by compiling to a Predicate<T>). Anybody know if this is possible at all? Marc
6
5686
by: DavidM | last post by:
Hi, Are there any libraries for manipulating algebraic expression trees? In particular, take an expression tree and simplify it down. I'm working up the next release of PyGene, the genetic programming and genetic algorithms library. Part of PyGene works with trees holding algebraic expressions. For example, the expression:
18
7977
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp defintion of "expression" and "statement"? What is the difference between an expression and a statement?
2
2111
by: Federico Zenith | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello everybody, I am looking into a problem that probably someone had before, so I hope I can avoid reinventing the wheel... I am looking into different alternatives to simulate a chemical process with a number of unit operations (heat exchangers, chemical reactors and so on). There are some commercial products (such as Hysys) that do this,
14
3726
by: serave | last post by:
How do i evaulate a mathematical expression that is entered in a text field. Ex: Text Fields: Xo=23 X1= 250 Expression: y = Xoe^(x1+Xo)-cos(X0+X1)+23Xo
56
6778
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under 6.4.2(2) : case constant-expression : I propose that the case expression of the switch statement be changed from "integral constant-expression" to "integral expression".
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.