Skip to main content

✍️ Practice (Easy)

1. Is Valid​

Create a function called IsValid which receives an integer and prints to console whether or not this integer is valid according to the following rule: The integer is valid if it is more than 0 and smaller than 100

2. Argument Order​

Consider the following code:

static int WeirdFunction (int i, int j, int k)
{
return (k + i) * 2 + j;
}

What will be the output when running this:

Console.WriteLine(WeirdFunction(2, 2, 2));
Console.WriteLine(WeirdFunction(1, 2, 3));
Console.WriteLine(WeirdFunction(3, 2, 1));

3. Summing squares​

Consider the following function:

static int SumSquares(int num1, int num2)
{
int result = num1 * num1 + num2 * num2;
return result;
}

What will be the output of this line of code:

Console.WriteLine(SumSquares(3, 4) + SumSquares(1, 2));

4. Is In Range​

Create a function called IsInRange that takes three numbers. The first number will be checked to see if it is between the second number (inclusive) and the third number (exclusive).

5. Tracing​

Consider the following functions:

static void Function1()
{
Console.WriteLine("Hi");
Function2();
Function3();
}

static void Function2()
{
Console.WriteLine("How are you?");
}

static void Function3()
{
Console.WriteLine("Bye");
}

What will be the output when running this:

Function1();

What will be the output when running this:

Function1();
Function2();
Function3();

6. Scope​

Consider the following code:

int value = 50;

static void Function1()
{
int value = 25;
Console.WriteLine(value);
}

What will be the output when running this:

Function1();
Console.WriteLine(value);