This Java program defines a class called AddTwoNumbers with a main method that declares three integer variables x, y, z. It assigns values of 10 to x and 20 to y, adds those values and assigns the sum to z, then outputs to the screen "Sum of x and y = " followed by the value stored in z.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
17 views
Class Addtwonumbers //class Declaration (
This Java program defines a class called AddTwoNumbers with a main method that declares three integer variables x, y, z. It assigns values of 10 to x and 20 to y, adds those values and assigns the sum to z, then outputs to the screen "Sum of x and y = " followed by the value stored in z.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
class AddTwoNumbers
//Class Declaration
public static void main(String args[]) //Main Function
{ int x, y, z; // Variable Declaration x = 10; //Assigning 10 to the variable x. y = 20; //Assigning 20 to the variable y. z = x + y; //Expression to Add two variables x, y and save the result to z System.out.println("Sum of x and y = "+z); //This line output the value of z on the Screen } }
CS / IT 425 C (CR) Iv/Iv B.Tech Degree Examination, March/April 2015 Second Semester CS/ It Cloud Computing Answer Question No. 1 Compulsory (14x1 14) Answer ONE Question From Each Unit 4x14 56