write a program to accept any ten values and find its sum.
Answers
Answered by
2
values = input("enter nums: ").split()
int_values = [int(n) for n in values]
print(f"sum: {sum(int_values)}")
Answered by
1
Question:-
Write a program to accept 10 values and display it's sum.
Program:-
This is written in Java.
import java.util.*;
class Sum
{
static void main()
{
Scanner sc=new Scanner(System.in);
int s=0;
System.out.println("Enter 10 numbers... ");
for(int i=1;i<=10;i++)
s+=sc.nextInt();
System.out.println("Sum is: "+s);
}
}
Similar questions