Write a function to multiply 2 numbers.


import java.util.*;

 

public class Functions {

 

   //Multiply 2 numbers

   public static int multiply(int a, int b) {

       return a*b;

   }

   public static void main(String args[]) {

       Scanner sc = new Scanner(System.in);

       int a = sc.nextInt();

       int b = sc.nextInt();

 

       int result = multiply(a, b);

       System.out.println(result);

   }

}



Share to whatsapp

More Questions from Java Basic Codes Module 0

Take an array of Strings input from the user & find the cumulative (combined) length of all those strings.


View

Write a function to multiply 2 numbers.


View

Searching for an element x in a matrix.


View

Print the spiral order matrix as output for a given matrix of numbers.


View

Write a program to print Fibonacci series of n terms where n is input by user :

0 1 1 2 3 5 8 13 21 ..... 

In the Fibonacci series, a number is the sum of the previous 2 numbers that came before it.


View

Take an array of names as input from the user and print them on the screen.


View

Write a function that takes in the radius as input and returns the circumference of a circle.


View