Java program to find sum of 2 number

Java program to find sum of 2 number
or
Java program to find addition of 2 number

Program:-

import java.util.Scanner;

class group{
public static void main(String arg[]){
int num1, num2, sum;
Scanner data = new Scanner(System.in);
// Reading 1st number
System.out.println("Enter 1st number");
num1 = data.nextInt();
//Reading 1st number
System.out.println("Enter 2nd number");
num2 = data.nextInt();
// Finding sum
sum=num1+num2;
//Displaying sum
System.out.println("sum:"+sum);
}
}


Output:-

Enter 1st number
25
Enter 2nd number
21
sum:46


Output:-

Enter 1st number
-25
Enter 2nd number
23
sum:-2


Output:-

Enter 1st number
25
Enter 2nd number
-21
sum:4


Output:-

Enter 1st number
-56
Enter 2nd number
-84
sum:-140





Learn Java:-
Java codes

Java Programs:-
List of Java Programs

9 Comments

  1. Thanks for sharing this program.It is really helpful.Continue sharing more like this.
    Regards,
    Java Training in Chennai | Java Training Institutes in Chennai | Java courses in Chennai

    ReplyDelete
  2. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
    Best hadoop training institute in chennai|Hadoop Training Chennai|Hadoop Training in Chennai

    ReplyDelete
  3. Nice Post! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep your blog as updated.
    Regards,
    cloud computing training in chennai|cloud computing training

    ReplyDelete
  4. Excellent post!!! The future of cloud computing is on positive side. With most of the companies integrate Salesforce CRM to power their business; there is massive demand for Salesforce developers and administrators across the world.Salesforce Training in Chennai | Salesforce Training Institutes in Chennai

    ReplyDelete
  5. Hi, you have given really informative post. Thanks for sharing this post to our vision. Learn Hadoop Online Training will helps you to reach your goal.Selenium Training

    ReplyDelete
  6. Good and nice informative article, thanks for sharing your information and views...
    Java Training institute in chennai | Best Java Training in velachery

    ReplyDelete

Add your comments here

Back to Top