Problem: Min Method (Return the Smaller Number) Create a method GetMin(int a, int b), which returns the smaller of two numbers. Write a program, which takes as input three numbers and prints the smallest of them. Use the method GetMin(…), which you have already created. Sample Input and Output Input Output Input Output 1 2 3 1 -100 -101 -102 -102 Hints and Guidelines Define a method GetMin(int a, int b) and implement it, after which invoke it from the main program as shown below. In order to find the minimum of three numbers, first, find the minimum of the first two and then the minimum of the result and the third number: var min = GetMin(GetMin(num1, num2), num3); References: Programming Basics with C#: Comprehensive Introduction to Programming with C#: Book + Video Lessons by Dr. Svetlin Ivanov NakovPaperback
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Problem: Min Method (Return the Smaller Number)
Create a method GetMin(int a, int b), which returns the smaller of two numbers. Write a program, which takes as input three numbers and prints the smallest of them. Use the method GetMin(…), which you have already created.
Sample Input and Output
Input | Output | Input | Output |
---|---|---|---|
1 2 3 |
1 | -100 -101 -102 |
-102 |
Hints and Guidelines
Define a method GetMin(int a, int b) and implement it, after which invoke it from the main program as shown below. In order to find the minimum of three numbers, first, find the minimum of the first two and then the minimum of the result and the third number:
var min = GetMin(GetMin(num1, num2), num3);
References:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images