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);

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

PLEASE NOTE: IT'S A TEXT BOOK EXERCISE.

BOOK NAME: Fundamentals of Computer Programming with Programming Basics with C# (English)

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);

Refences:

  • Title: Programming Basics with C#
  • Authors: Svetlin Nakov & Team
  • ISBN: 978-619-00-0902-3 (9786190009023)
  • Edition: Faber Publishing, Sofia, 2019

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning