Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-16-2012, 04:10 AM   PM User | #1
jeckel7234
New to the CF scene

 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jeckel7234 is an unknown quantity at this point
need help, student

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
straw is 1
red is 3
purple is 0.3e+1
Write your answer in the form: variable is assigned value

white = color * 2.5 / purple;
green = color / purple;
orange = color / red;
blue = (color + straw) / (crayon + 0.3);
lime = red / color + red % color;
purple = straw / red * color;
jeckel7234 is offline   Reply With Quote
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
Old 09-16-2012, 05:34 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Modulo isn't the same in all languages, but I can't think of a C based language that doesn't use % as modulo. Always check the language basics documentation as they will indicate what the arithmetic and bitwise operations are (which I find are the ones that change the most). For example, in visual basic you use the Mod operator. Unfortunately implementation of modulo also changes slightly between languages.
The 'e' in this example isn't euler. Its exponent, so this is a block written an scientific notation. 0.3e+1 is the same as 3.0.
Fou-Lu is offline   Reply With Quote
Old 09-25-2012, 08:55 AM   PM User | #4
krishvandam
Banned

 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
krishvandam is an unknown quantity at this point
hello hi ! I am here for introduce you new kind software and hardware
in few days there many type of tech gadgets are come and they can do as fast as
your expectation and give you new better experience awareness is this period of time and make our life more smooth and better so I want give you that news.
If want more information about this software click the link on ATI RADEON HD 5670 – SERIES GRAPHICS CARDS FROM AMD.
The information about new hardware ATI Radeon HD 5670 is not anything but graphics card hardware software that provides superb act. operates below 75 watts .
----------------------------------------------------
ATI RADEON HD 5670 – SERIES GRAPHICS CARDS FROM
krishvandam is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:12 AM.


Advertisement
Log in to turn off these ads.