14,736,834 members
See more:
After loading a file of math equations into my program I have to somehow parse the equation and calculate the correct answer.

Here's the file of math problems:

2 + 2
10 + 12
9 + 7
0 + 8
5 - 3
19 - 8
9 * 4
6 * 7
11 * 12
16 / 4
100 / 5
36 / 9

What I have tried:

```using System;
using System.I0;

class program
{
static void Main(string[]args)
Console.WriteLine(\$"Welcome to the math quiz game!");

Posted
Updated 1-Apr-20 17:17pm
Maciej Los 31-Mar-20 2:31am

How many times you want to ask the same question?
This is the 1. one!

## Solution 1

First of all choose a language, because C++ and C# are bot the same.
Quote:
How do I parse a math equation using string manipulation?

Both languages are documented a little Google will give you plenty of links to documentation and tutorials. You will learn much more this way and you will find it very useful in future.

If your formulas are not more complex, simply detecting spaces and splitting to 3 strings is enough, in second string you will get the operator.
If formulas can be more complex (2 + 3 * 4 and more), you will need a parser and take into account priority of operators.

By the way, your snipset of code is not C++ neither c#
CPallini 31-Mar-20 2:12am

5.
Patrice T 31-Mar-20 5:49am

Thank you

## Solution 2

Yo've got 2 answers to your latest question here: How to convert file content to numbers in visual studio[^]
CPallini 2-Apr-20 2:12am

(On behalf of Member 14789845):
we have the same HW and I am still looking for the solution. lol