Calculation (1 Viewer)

HY2000

New member
Local time
Today, 09:27
Joined
Jun 27, 2018
Messages
8
Q: Determine the values (in integers) of a, b, and c of the following expressions,
I) a= 21+15%2*3;
II) b= (10-8)*5%2;
III) c= 17%(7%(8-4));

I have no idea how to calculate a,b,c value and show steps, I need some help:confused:

Thank you!!
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:27
Joined
Sep 21, 2011
Messages
14,257
BEDMAS ?

Brackets
Exponential
Division
Multiplication
Addition
Subtraction
 

isladogs

MVP / VIP
Local time
Today, 17:27
Joined
Jan 14, 2017
Messages
18,211
I don't understand what the expressions mean due to the badly written use of %
For example, is that a = 21 + (0.15 * 2/3) = 21.1
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:27
Joined
Feb 28, 2001
Messages
27,162
HY2000 - if this is for a class, you are not helping yourself very well. The method to do these kinds of things SHOULD have been covered.

I agree with Colin (isladogs) that your #I expression is not written in standard format, in such a way as to be ambiguous. #II suffers from the same problem.

Here is a hint: IN GENERAL when you put two quantities side-by-side in common human notation, your intent is multiplication. Like if A and B are two variables, A B usually means A TIMES B, which in programming is A * B. Starting from there, perhaps you can proceed.

However, what is more confusing is "show your steps" because none of those problems requires any steps - unless you are seeking to program them in some type of Assembly language. In which case, you are VERY far afield. What is meant by "show your steps?"
 

plog

Banishment Pending
Local time
Today, 11:27
Joined
May 11, 2011
Messages
11,643
% = modulus (the remainder of whole division)

5 % 3 = 2

I suggest you talk to your teacher or perhaps a fellow student. Honestly, this is first week Comp 101 stuff; its a month into classes---you might consider dropping the class.
 

Scribtor

Registered User.
Local time
Today, 18:27
Joined
Sep 27, 2018
Messages
16
BEDMAS ?

Brackets
Exponential
Division
Multiplication
Addition
Subtraction


:banghead:

What he said :D




This is the beginning and the end of your problem and it states the priority of operation in mathematics, and OF COURSE, programming


All of us at one time or another make mistakes and stumble somewhere, but most commonly it's either "BEDMAS" or missing syntax for closing statements


One other thing

You can never do too much brackets
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:27
Joined
Feb 28, 2001
Messages
27,162
You can never do too much brackets

Although if you have a complex query create in the query design grid and it has a couple of layers of alternate criteria, the SQL generator CAN do too many brackets.
 

Scribtor

Registered User.
Local time
Today, 18:27
Joined
Sep 27, 2018
Messages
16
Write queries directly without any support-wheels, therefore making sure you can only have less-than-enough brackets :D
 

Users who are viewing this thread

Top Bottom