write a program to calaculate the sum of 10 numbers
Answers
Answered by
1
Answer:
Explanation:
#include<iostream>
using namespace std;
int main()
{
int i=1,sum=0;
while(i<=10)
{
sum+=i;
i++;
}
cout<<"Sum :"<<sum;
return 0;
}
Answered by
0
Python program :
Explanation:
Sum=0.00# Variable which holds the sum value.
for x in range(10):#For loop which runs from 1 to 10.
number=float(input("Enter the number : "))#Take the user input for 10 value.
Sum=Sum+number#Add the value.
print("The Sum of ten number is : ",Sum)#Print the sum.
Output :
- If the user gives the input as "1,1,1,1,1,1,1,1,1,1,1", then the output is 10.
- If the user gives the input as "1,1,1,1,1,1,1,1,1,1,3", then the output is 12.
Code Explanation:
- The above code is in python language, which takes the 10 value and prints the sum value.
- The program has a for loop which runs at 10 times and takes the 10 value and adds it to the sum variable.
- Then the value of a sum variable will be printed with the help of print function.
Learn More :
- Python : https://brainly.in/question/14689905
Similar questions