## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

###### moonlightflower

3,987 Points# C# Basics Integers and Doubles Quiz Q7

Hi, hoping someone can help me understand the maths in this question, I've tried several times and it just isn't clicking for me.

```
int a = 3;
int b = 2;
double c = 3.5;
double y = a / b * c;
```

y = ?

How I'm understanding it is:

First: b * c

```
2 * 3.5 = 7.0
```

Then: a / 7.0

```
3 / 7.0 = 0.4285714285714286
```

So: y = 0.4285714285714286

It's incorrect, so what am I doing wrong here..?

###### moonlightflower

3,987 PointsThank you Fatima! Very clear and concise, I see what I did now.

###### Steven Parker

212,135 Pointsfatima Tavakoli — You might consider posting your response as an answer instead of a comment. That would allow voting and give the original asker the option of selecting it as "best answer". If I were a mod, I'd promote it for you.

###### Fatemah Tavakoli

13,797 PointsSteven Parker Thank you for pointing out :D I posted as an answer.

###### Fatemah Tavakoli

13,797 Pointsmoonlightflower you are welcome :)

## 1 Answer

###### Fatemah Tavakoli

13,797 PointsYou have to consider the order of operations in math and also the type of variables (double and integer). Since we dont have parentheses and division and multiplication are in same order, we have to calculate them from left to right. First a\b = 3/2 = 1.5 but since a and b both of them are integer the result will be integer too => a/b = 1 And then 1 * 3.5 = 3.5.

**Order of math operations:**

- Parentheses.
- Exponents.
- Multiplication and Division (from left to right).
- Addition and Subtraction (from left to right).

## Fatemah Tavakoli

13,797 Points## Fatemah Tavakoli

13,797 PointsYou have to consider the order of operations in math and also the type of variables (double and integer). Since we dont have parentheses and division and multiplication are in same order, we have to calculate them from left to right. First a\b = 3/2 = 1.5 but since a and b both of them are integer the result will be integer too => a/b = 1 And then 1 * 3.5 = 3.5.

Order of math operations: 1.Parentheses 2.Exponents 3.Multiplication and Division (from left to right) 4.Addition and Subtraction (from left to right)