Make a program: functions and subroutines
- a01337106
- 10 feb 2015
- 1 Min. de lectura
Now that we know the basics of pseudocode, we are going to learn functions, this is a function:
public class Sumar{
int a=10;
int b=5;
public static int suma(number a,b){
int sum;
sum=a+b;
}
}
First, a class is initialized, the name of this class will be "Suma":
public class Sumar{
Then a function is opened:
public static int suma(number a,b){
"public" refers to the persons or programs that can access to the method.
"int" refers to the value returned by the method.
"suma" is the name of the method
(number a,b) refers to the variables that are called inside the method.
Then, inside the method, is the code that will be executed, in this case is a sum between a and b.
int sum;
sum=a+b;
Finally you close the method and the class:
}
}
Comments