O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required