Programming Tutorial > Task 1–2: Defining Functions
  
Task 1–2: Defining Functions
1. Define a function that checks whether a number is positive:
After you define a function, you can call it and use it with parameters, such as numbers and variables.
2. Call the function with different values and verify that it returns 1 for positive numbers and 0 for nonpositive numbers as shown below.
3. Define a function that calculates the greatest common divisor and the difference of two numbers:
* 
You can use any PTC Mathcad built-in function, such as gcd, inside a program.
4. Check the value of f(57,48).
The function output is a two-element vector. The first number is the greatest common divisor of the two input numbers and the second number is the difference between them.
Proceed to Task 1–3.