1# This program adds two numbers
2
3num1 = 1.5
4num2 = 6.3
5
6# Add two numbers
7sum = float(num1) + float(num2)
8
9# Display the sum
10print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
11
1// program to add two numbers using a function
2
3#include <iostream>
4
5using namespace std;
6
7// declaring a function
8int add(int a, int b) {
9 return (a + b);
10}
11
12int main() {
13
14 int sum;
15
16 // calling the function and storing
17 // the returned value in sum
18 sum = add(100, 78);
19
20 cout << "100 + 78 = " << sum << endl;
21
22 return 0;
23}