Friday, 20 October 2023

JAVA

product of two numbers using functions

Lets get started

 
       
  1. /* here we are going to create a function that will return product of two numbers */
  2. import java.util.* ;
  3. public class MINtech{
  4. public static void main(String args[]){
  5. Scanner sc = new Scanner(System.in);
  6. int a = sc.nextInt() ;
  7. int b = sc.nextInt() ;
  8. // calling the function
  9. int result = doSomething(a,b) ;
  10. // printing the result
  11. System.out.println(result);
  12. }
  13. // creating the function
  14. public static int doSomething(int a , int b ){
  15. return a*b ;
  16. }
  17. }

Output

    4
    8
    32

    100
    200
    30000

    2024
    2023
    4094552
        
`

No comments:

Post a Comment