Learning C# 2005: Get Started with C# 2.0 and .NET Programming (2nd Edition)

4.7. Exercises

Exercise 4-1 .

Write a program that assigns the value 25 to variable x , and 5 to variable y . Output the sum, difference, product, quotient , and modulus of x and y .

Exercise 4-2 .

What will be the output of the following method?

static void Main( ) { int varA = 5; int varB = ++varA; int varC = varB++; Console.WriteLine( "A: {0}, B: {1}, C: {2}", varA, varB, varC ); }

Exercise 4-3 .

Write a program that demonstrates the difference between the prefix and postfix operators.

Категории