Respuesta :
Answer:
C++ code
Explanation:
C++ code
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
double first,second,third;
cout<<"Enter first Decimal :";
cin>>first;
cout<<"Enter second Decimal :";
cin>>second;
cout<<"Enter third Decimal :";
cin>>third;
cout<<"Sum of three decimal = "<<first+second+third;
return 0;
}
Code Explanation
Decimal numbers are stored in double data types.
So first declare three variables and then get input by using cin from command line.
At the end display there sum by addition of all three variables.
Output
Enter first Decimal :10.22
Enter second Decimal :20.22
Enter third Decimal :9.99
Sum of three decimal = 40.43
Answer:
i = 0
total = []
print('Enter 3 decimal numbers')
while i < 3:
num = float(input(str(i+1)+')'))
i += 1
total.append(num)
print('sum = ',sum(total))
Explanation:
The programming language used is python.
The code prompts the user to Enter three decimal numbers, accepts the numbers and then outputs the sum.
A WHILE loop is used to collect the three numbers and the numbers are stored in a list using the append method. finally we make use of the list attribute sum, to evaluate the sum of the three numbers inputted.
A picture is attached for you to see how the code behaves.
