Wednesday, 10 July 2013

Program For Sum of integers using java

import java.io.*;
public class Suminteger
{
        public static void main(String ap[]) throws IOException
        {
                InputStreamReader i=new InputStreamReader(System.in);
                BufferedReader br=new BufferedReader(i);
                int a,b,s;  // we have taken three variables,a and b for inserting values and s for storing Sum of a and that is a+b
                System.out.println("enter value of a and b");
                a=Integer.parseInt(br.readLine());
                b=Integer.parseInt(br.readLine());
                s=a+b;
                System.out.println("sum="+s);
        }
}

No comments:

Post a Comment