English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

4 answers

This answer gives both Python and Java:

Python:

def add(num1, num2):
--- return num1+num2

Java:

int add(int num1, int num2){
---- return num1+num2;
}

The "---"s are just to show indentation.

2007-12-21 10:42:09 · answer #1 · answered by Ricky V 2 · 1 2

Well I can't see a real use for this function, but:
public add( int x, int y) { return (x + y); };

2007-12-20 03:54:47 · answer #2 · answered by Chris C 7 · 0 1

Java:

public class AddIntegers {

public static void main(String args[]) {
int firstNumber = Integer.parseInt(args[0]);
int secondNumber = Integer.parseInt(args[1]);

int finalNo= addIntegers(firstNumber, secondNumber);
System.out.println("After addition :" + finalNo);
}

private static int addIntegers(int firstNo, int secondNo) {
return firstNo+secondNo;
}
}

2007-12-20 03:57:24 · answer #3 · answered by moumita_d 2 · 0 0

public add(int x,int y){
int sum=0;
sum=x+y;
return sum;
}

hope it helps. =)

2007-12-20 03:49:15 · answer #4 · answered by x0rr 2 · 0 0

fedest.com, questions and answers