Computer Science, asked by yeshukiraah, 3 months ago


9. Write a program to perform basic arithmetic operations through methods by passing actual arguments from calling
statement​

Answers

Answered by himanshu2006vps
1

import java.io.*;

class Main

{

// create a method

public int addNumbers(int a, int b)

{

int sum = a + b;

// return value

return sum;

}

public static void main(String[] args)

{

int num1 = 25;

int num2 = 15;

// create an object of Main

Main obj = new Main();

// calling method

int result = obj.addNumbers(num1, num2);

System.out.println("Sum is: " + result);

}

}

Similar questions