p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 (http://p2p.wrox.com/forumdisplay.php?f=400)
-   -   Correction to page 49 (http://p2p.wrox.com/showthread.php?t=76270)

SeanDunn September 22nd, 2009 03:26 AM

Correction to page 49
Not that it is that important but if you wanted to reuse the code.

The text in the WriteLine for subtraction states that you subtract firstNumber from secondNumber when infact the code subtracts secondNumber from firstNumber.

Will September 23rd, 2009 04:47 PM

I noticed this as well it should be:


double firstNumber, secondNumber;
            string userName;
            Console.WriteLine("Enter your name");
            userName = Console.ReadLine();
            Console.WriteLine("welcome {0}!", userName);
            Console.WriteLine("Now give me a number:");
            firstNumber = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("now give me another number:");
            secondNumber = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("the result of subtracting {0} and {1} is {2}.", firstNumber, secondNumber,
                firstNumber - secondNumber);

sh_erfan November 7th, 2009 04:45 AM

As will said the code is correct.It states that you subtract secondNumber from firstNumber.

pay attention to this code:
x=firstNumber - secondNumber;
this means that you lessen socondNumber from firstNumber and assign it to x(a vriable to hold value).so the statement we order the compiler to do in this code is "subtract secondNumber form firstNumber".

I hope could help


jawadh_khan786 January 3rd, 2010 01:00 AM

Pay attention here
Hello C# learners and programmers

Depending on your query here... please pay attention on the page no. 47, and in the table provide observe carefully the second row on -(subtraction operator)

Operator is:

category: Binary
Eg Expression:

var1 = var2 - var3
var1 is assigned the value that is the value of var3 subtracted from the value of var2.


if we want to subtract 5(firstNumber) from 10(secondNumber) then the code below is invalid


Console.WriteLine("The result of subtracting {0} from {1} is: {2}.", firstNumber, secondNumber, firstNumber - secondNumber);
Execution of above code gives annoying result


The result of subtracting 5 from 10 is: -5
Hence the code below is perfectly valid


Console.WriteLine("The result of subtracting {0} from {1} is: {2}.", firstNumber, secondNumber, secondNumber - firstNumber);

Regards C# expert

All times are GMT -4. The time now is 12:23 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.