java program to caculate sum of integers
program code
import java.io.*;
import java.util.*;
class Sum
{
public static void main(String args[])throws Exception
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
int a[]=new int[10];
int i,sum=0;
System.out.println("enter integer:\n");
for(i=0;i<10;i++)
{
a[i]=Integer.parseInt(br.readLine());
}
for(i=0;i<10;i++)
{
System.out.println("integers are:"+a[i]);
}
for(i=0;i<10;i++)
{
sum+=a[i];
}
System.out.println("sum is:\n"+sum);
}
}
No comments:
Post a Comment