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

26 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
  7. There are lots of information about oracle have spread around the web, but this is a unique one according to me. keep sharing your post.
    No.1 Java Project Center in Chennai | Best Dot Net Projects in Chennai | Best Mini Project Center in Chennai


    ReplyDelete
  8. Thanks for your post; java is most trusted language to validate web browser. This language provides precise and complete information about an application or environment. 
    Best Android Training Institute in Chennai | DotNet Training Institute in Chennai | Web Designing Training Institute in Chennai

    ReplyDelete
  9. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    big data training in bangalore

    ReplyDelete
  10. I gained more knowledge from your blog..thanks for sharing innovative blog..Java Project Center in Chennai | Java Project Center in Velachery

    ReplyDelete
  11. Great Blog, you have posted posted something new compared to others, I read many article related to this topic but no one explain like this much of clear manner. Best CCNA Training Institute in Chennai | Best CCNP Training Institute in Chennai | Hardware & Networking Training in Chennai

    ReplyDelete
  12. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    aws training in Chennai

    ReplyDelete
  13. Those guidelines additionally worked to become a good way to
    recognize that other people online have the identical fervor like mine
    to grasp great deal more around this condition.

    white label website builder

    ReplyDelete
  14. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    digital marketing training in chennai

    ReplyDelete
  15. It is a one of the great discussion which is very essential for me as well. I must follow the handy discussion and sure that the content will be very useful to me as well. Keep it up. C, C++ Summer Course in Medavakkam | C, C++ Summer Course in Tambaram | C, C++ Summer Courses in Velachery

    ReplyDelete
  16. Nice blog, thank you. A page is being visited more in mobile than pc, so we need to make it as priority as well.
    Good Summer Courses in Porur | Perfect Summer Course in Guindy

    ReplyDelete

Add your comments here

Back to Top