Programming Examples
Java program to input 10 integers and find their sum.
Write a program to input 10 integers and find their sum.
Solution
class Sum10
{
public static void main(Strign arr[])
{
Scanner sc=new Scanner(System.in);
int i,n,s=0;
System.out.println("Enter 10 integers:");
for(i=1;i<=10;i++)
{
n=sc.nextInt();
s=s+n;
}
System.out.println("Sum of the numbers="+s);
}
}
Output