Programming Exercises

   


Make the following changes to the program in Listing 4.1:

1:

Change the multi-line comments in lines 3 6 to two single line comments.

2:

Apart from addition and multiplication, allow the user to perform a subtraction. Among other changes, you need to add a Subtract method. (The symbol is used to perform subtractions in C#).

3:

Instead of calculating the sum and the product of two numbers, make the program perform the calculations on three numbers. (You can ignore the Max and Min functions here.) Hint: You need to declare another int variable in Main. The Sum, Product, and Subtract methods must accept three arguments instead of two. You must allow the user to input a third number, and you must include the third argument when these methods are called.

4:

Create two methods called MyMax and MyMin that both take three arguments and find the maximum and minimum value of these arguments. Hint: Math.Max(Math.Max(a, b),c) returns the max of a, b and c.


   


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net