9. Write a program to perform basic arithmetic operations through methods by passing actual arguments from calling
statement
Answers
Answered by
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
Math,
1 month ago
India Languages,
3 months ago
Math,
3 months ago
English,
9 months ago
Political Science,
9 months ago