Member-only story
Step 3: Testing the algorithm by implementing it.
To test the algorithm, let’s implement it in the C language.
Program
C++
// C++ program to add three numbers
with the help of the above-designed
// algorithm
cpp#include <bits/stdc++.h>
using namespace std;
int main()
{
// Variables to take the input of
// the 3 numbers
int num1, num2, num3;
// Variable to store the resultant sum
int sum;
Take the 3 numbers as input.
cout << "Enter the 1st number: ";
cin >> num1;
cout << " " << num1 << endl;
cout << "Enter the 2nd number: ";
cin >> num2;
cout << " " << num2 << endl;
cout << "Enter the 3rd number: ";
cin >> num3;
cout << " " << num3;
// Calculate the sum using the + operator.
// and store it in the variable sum