-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexmple.cpp
More file actions
36 lines (26 loc) · 833 Bytes
/
exmple.cpp
File metadata and controls
36 lines (26 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;
// Function to add two numbers
//numbers should be whole numbers
double add(double num1, double num2) {
return num1 + num2;
}
// Function to multiply two numbers
double multiply(double num1, double num2) {
return num1 * num2;
}
int main() {
double num1, num2;
// Asking for user input
cout << "Enter first number: ";
cin >> num1;
cout << "Enter second number: ";
cin >> num2;
// Calling add function and displaying the result
double sum = add(num1, num2);
cout << "The sum of " << num1 << " and " << num2 << " is: " << sum << endl;
// Calling multiply function and displaying the result
double product = multiply(num1, num2);
cout << "The product of " << num1 << " and " << num2 << " is: " << product << endl;
return 0;
}