View Single Post
Old 09-16-2012, 02:15 PM   PM User | #2
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
Quote:
Originally Posted by jeckel7234 View Post
Im taking my first class in C++ and im having a hard time understanding it all, ive been stuck on this problem for some time now, can anyone give me a clue what e stands for in purple and how to react to the % sign on the question lime? Thanks again


Assume that you have the following variable declarations:

int color, lime, straw, yellow, red, orange;
float black, white, green, blue, purple, crayon;

Evaluate each of the statements below given the following values:
color is 2
black is 2.5
crayon is -1.3

lime = red / color + red % color;
purple = straw / red * color;
In every programming language, the % sign is for the modulo mathematical operation. The result of R%T is the remainder when you do
R÷T.
Examples:
4%2 = 0 ; // Because 4 divides 2 to leave no remainder

7%2 = 1;
50%6 = 2;
88%9 = 7;

So for and so forth. It is useful when comparing divisibilty, finding out whether a number is a factor of another or when getting remainders from divisions.

As for e , I believe that that's Euler's number. http://en.m.wikipedia.org/wiki/E_(mathematical_constant) . You can find it in the math library or to calculate it yourself --> http://stackoverflow.com/questions/3...cal-constant-e
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk

Last edited by Redcoder; 09-16-2012 at 06:07 PM.. Reason: Modulo is not the same in all languages..but it is represented as % in most if not all C-based languages
Redcoder is offline   Reply With Quote