Question: Follow the instructions for starting C++ and viewing the SwatTheBugs25.cpp file, which is contained in either the Cpp8Chap10SwatTheBugs25 Project folder or the Cpp8Chap10 folder. (Depending
Follow the instructions for starting C++ and viewing the SwatTheBugs25.cpp file, which is contained in either the Cpp8\Chap10\SwatTheBugs25 Project folder or the Cpp8\Chap10 folder. (Depending on your C++ development tool, you may need to open this exercises project/solution file first.) The program should calculate and display the sum of two numbers, but it is not working correctly. Debug the program Ok so I worked the problem and this is what I came up with but when I run the code it will still not add the numbers, what am I missing. I need to use & and not *, so with that in mind what is my error that does not allow the function to calculate. //SwatTheBugs26.cpp - displays the sum of two numbers //Created/revised by on #include using namespace std; //function prototypes void getNumber(int num); void calcSum(int n1, int n2, int &n3); int main() { int num1 = 0; int num2 = 0; int num3 = 0; //enter input items getNumber(num1); getNumber(num2); //calculate and display sum calcSum(num1, num2, num3); cout << "Sum: " << num3 << endl; system("pause"); return 0; } //end of main function //*****function definitions***** void getNumber(int num) { cout << "Enter a number: "; cin >> num; } //end of getNumber function void calcSum(int n1, int n2, int &n3) { n3 = n1 + n2; } //end of calcSum function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
