Hi guys...

I've downloadws today the IronPython. One thing i've noticed that if you type, for example, 5+6 it calculates it..!

So, i tried to do that with my App too, without success...

Note: I've tried "if" sentences, but they are pretty useless...

Help!

Anyone..?

Um, what? It sounds like you want to write an interpreter, but your question was so freaking vague I can't be sure. :icon_rolleyes:

I've downloadws today the IronPython. One thing i've noticed that if you type, for example, 5+6 it calculates it..!

So, i tried to do that with my App too, without success...

You should be able to get this going with std::cin.

Here's a quick example:

#include <iostream>

int main()
{
	int number1, number2;
	char mathsOperator;

	std::cout << "Enter a sum. (E.g. '1 + 3')" << "\n";
	std::cin >> number1;
	std::cin >> mathsOperator;
	std::cin >> number2;

	std::cout << "\n";

	switch( mathsOperator )
	{
	case '+':
		std::cout << "The Answer Is: " << number1 + number2 << "!\n\n";
		break;
	default:
		std::cout << "Invalid Operator!\n\n";
		break;
	};
}

I'll let you add the other operators. :)

All the best,
Adam

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.