Hi I'm taking an intro to C++ class. I'm lost on a HW assignment Trace to find the value assigned to e. Assume a, b, c are integer, d and e are double.

a. a = 3; b = 4;

b. c = ( a % b ) * 6

c. d = c / b;

d. e = ( a + b + c + d ) / 4;

If anyone can be of some help. I would really appreciate it I'm completely lost on this part of my HW assignment.

a. a = 3; b = 4;

b. c = ( a % b ) * 6

c. d = c / b;

d. e = ( a + b + c + d ) / 4;

If anyone can be of some help. I would really appreciate it I'm completely lost on this part of my HW assignment.

I can give some guidelines. ASSUME each line is markings on your paper:

Now you made marking to your paper: each "a" will represents number 3 and "b" represents number 4.

In this row you say: INTEGER c is equal to what ever is leftover on dividision 3/4 and multiple it by 6 -> a%b=3%4=**3** -> c=**3***6=18

You said d is double so: c=18, b=4 -> d=c/b ->d=18/4->d=4.5

This is easy is it yeah?

a=3

b=4

c=6

d=4.5...

make rest yourself

EDIT: error on maths. ty chervil below

a. a = 3; b = 4; |

Now you made marking to your paper: each "a" will represents number 3 and "b" represents number 4.

b. c = ( a % b ) * 6 |

In this row you say: INTEGER c is equal to what ever is leftover on dividision 3/4 and multiple it by 6 -> a%b=3%4=

c. d = c / b; |

You said d is double so: c=18, b=4 -> d=c/b ->d=18/4->d=4.5

d. e = ( a + b + c + d ) / 4; |

This is easy is it yeah?

a=3

b=4

c=6

d=4.5...

make rest yourself

EDIT: error on maths. ty chervil below

Last edited on

Yes I'm still lost can you clarify a little bit more please. For the first if a =3 b=4 then how would you solve it ?

The words make sense. but the numbers don't.

What is 3%4 ?

3 divided by 4 is 0, remainder 3.

What is 3%4 ?

3 divided by 4 is 0, remainder 3.

a. b. c. and d. are steps you need to take to get final answer.

removed step indicators. You were asked to produce final answer. Nothing more

EDIT: oops (ty chervil)

a = 3; b = 4; c = ( a % b ) * 6 d = c / b; e = ( a + b + c + d ) / 4; |

removed step indicators. You were asked to produce final answer. Nothing more

EDIT: oops (ty chervil)

Last edited on

Topic archived. No new replies allowed.