1. ## Quick question

Im relatively new to C. On Tuesday we have a small test on simple things. On the sample test I have managed to answer many of the questions however I cant seem to solve a simple expression having to do with double and int. The question is:

1. What is the value of the following expression in C? Assume a=5, b=7, c=3.2, d=5.0.

a,b=int
c,d,e=double

e=b/a*c+c*d

From what my friend says, the answer is 19.2; however I do not know how he came to that conclusion. I know the book definitions of int and double, but I cant seem to apply it to this expression. I would appreciate it if someone could show me the process to solving it.

2. Why don;t you put it into a compiler and find out the answer for yourself?
Code:
```#include <stdio.h>

int main(void)
{
int a=5, b=7;
double c = 3.2, d = 5.0, e;
e = b / a * c + c * d;
printf("%lf",e);
return 0;
}```

3. Looks like an attempt to make you understand the difference between integer and floating point division.

4. Well I could put it into pico (we use Unix) but its a written thing so putting it in a compiler wont help. I have to solve everything by hand.

5. Look up order of precedence and associativity in your C book, then work through it according to those rules.

6. Originally Posted by Dave_Sinkula
That's an interesting read, but it does also point out that you can rely on operator precedence rules in C as long as you don't think it has anything to do with order of evaluation. Since we are dealing with simple numeric constants and not anything with side effects, this is no problem.