44.8k views
4 votes
Write a program that accept three decimal numbers as input and outputs their sum

User Sdjuan
by
4.5k points

2 Answers

0 votes

Answer:

To translate C++ Into python REWRITE the code entirely

Step-by-step explanation:

Translated to python language (answer)

sum = 0.0

for i in range(0,3):

sum += float(input("Enter a decimal number to sum: "))

print ("Sum: ", sum)

________________________________________________

Given: #include <iostream>

using namespace std;

int main()

{

//Declare three variable to store three decimal numbers.

double num1, num2, num3;

//Taking input for three decimal number from user.

cout<<"Enter three numbers"<<endl;

cin>>num1>>num2>>num2;

//Displaying sum of three numbers to user.

cout<<"The sum of three numbers is: "<<num1+num2+num3<<endl;

return 0;

}

User Orges
by
4.8k points
3 votes

Answer:

#include <iostream>

using namespace std;

int main()

{

//Declare three variable to store three decimal numbers.

double num1, num2, num3;

//Taking input for three decimal number from user.

cout<<"Enter three numbers"<<endl;

cin>>num1>>num2>>num2;

//Displaying sum of three numbers to user.

cout<<"The sum of three numbers is: "<<num1+num2+num3<<endl;

return 0;

}

Step-by-step explanation:

Since no programming language is mentioned therefore this problem is solved using C++.

Above program will ask user to enter three decimal numbers and store these values in variable num1, num2 and num3.

After that the program will add the three values within cout statement and display it to user.

User Asqan
by
4.6k points