Computer Science, asked by ashwin41566, 7 months ago

Write a java program for addition of two number.
[Initialization of Variables).​

Answers

Answered by anindyaadhikari13
4

Question:-

Write a program in Java to perform addition of two numbers.

Program:-

class Addition

{

public static void main(String args[])

{

double a=20.0;

double b=10.0;

System.out.println("Result is: "+(a+b));

}

}

Answered by thehelpingguy
0

Answer: here is the cod

import java.util.Scanner;

class Main

{

public static void main(String[] arg)

{

int a,b,c;

Scanner sc=new Scanner(System.in);

System.out.println("Enter first number");

a=sc.nextInt();

System.out.println("Enter second number");

b=sc.nextInt();

c=addition(a,b);

System.out.println(" Addition of two numbers is : "+c);

}

static int addition(int x,int y)

{

return x+y;

}

}

Similar questions