Computer Science, asked by vicky37, 1 year ago

Fill in the blanks to print the sum of the two variables.

int x = 2; int y = 4;
int result = x 

 

 

 

 

 

;
System.out.println(

 

 

);

Answers

Answered by megha19
4
system.out.println (x+ y or result+y )
Answered by Jasleen0599
0

System.out.println(result );

Print the sum of the two variables.

int x = 2; int y = 4;

int result = x ;

System.out.println(result );

  • Finding the sum of two or more numbers is incredibly simple in Java. Declare and initialise the first two variables that will be added. To hold the total of the numbers, add another variable. Apply the plus sign (+) to the declared variable, then store the outcome. The sum of two numbers is computed and printed by the software that follows.
  • We can read user input thanks to the Java Scanner class. We pass two numbers to the user-defined method sum as input (). The approach is used in the following programme to compute the sum of two numbers and print the result.

#SPJ2

Similar questions