# Write a Program C++ & Python to calculate the sum of two numbers

Posted in  Vinay Khatri
Last updated on July 21, 2022

In this program, we will ask users to enter 2 numbers and print their sum as an output. Learn to calculate the sum of two numbers. For example, if the user enters 2 numbers 3.2 and 4.5 the output should be 7.7

## C++ Program to calculate the sum of two numbers

``````#include<iostream.h>
#include< conio.h>
#include<math.h>
void main()
{
clrscr();
cout<<"Enter the first number: ";
cin>>num_1;
cout<<"Enter the second number: ";
cin>>num_2;
cout<<"The sum of both the numbers is: "<<num_1+num_2;
getch();
}``````

Output:

``````Enter the first number: 4.7
Enter the second number: 3.4
The sum of both the numbers is: 8.1``````

## Python Program to calculate the sum of two numbers

``````num_1= float(input("Enter the first number: "))
nun_2= float(input("Enter the second number: "))
print("The sum of both the numbers is:",num_1+nun_2)``````

Output:

``````Enter the first number: 4.7
Enter the second number: 3.4
The sum of both the numbers is: 8.1``````

People are also reading:

##### Tags:
calculate the sum of two numbers