Write a Java program to find the sum of given number 10 20 and 30.
//With direct Assiging the value to variable
class SumOfElement{
public static void main(String args[]){
int a=10, b=20, c=30;
int sum = 0;
sum=a+b+c;
System.out.println("Sum of elements is:"+sum);
}
}
//With taking user Input
class SumOfElement{
public static void main(String args[])
{
Scanner it =new Scanner(System.in);
System.out.println("Enter 1st elements ");
int a=it.nextInt();
System.out.println("Enter 2st elements ");.
int b=it.nextInt();
System.out.println("Enter 3st elements ");.
int c=it.nextInt();
int sum = 0;
sum=a+b+c;
System.out.println("Sum of elements is:"+sum);
}
}