Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m getting a LNK1120 error, but I don\'t see any errors on my end. Please revi

ID: 3657295 • Letter: I

Question

I'm getting a LNK1120 error, but I don't see any errors on my end. Please review the programming code below for accuracy, if you are able to identify the syntax error, please bring it to my attention. Thanks.

//Exercise6.cpp

//Created/revised by <LuckyButch> on <Nov 23, 2012>

#include <iostream>

#include <iomanip>

using namespace std;

//function prototype

void calcSumAndDiff(int n1, int n2, int sum, int diff);

int main()

{

//declare variables

int num1 = 0;

int num2 = 0;

int numSum = 0;

int numDiff = 0;

//get input items

cout << "First number: ";

cin >> num1;

cout << "Second number: ";

cin >> num2;

//Adding and subtracting the numbers

calcSumAndDiff(num1, num2, numSum, numDiff);

//display the sum and difference

cout << "Sum: " << numSum << endl;

cout << "Difference: " << numDiff << endl;

system("pause");

return 0;

} //end of main function

//*****function definitions*****

void calcSumAndDiff(int n1, int n2, int sum, int diff)

{

sum = n1 + n2;

diff = n2 - n1;

} //end of calcSumAndDiff function

?

?

?

?

Explanation / Answer

//the sum and diff needs to be passed by reference, so your prototype and function is: void calcSumAndDiff(int n1, int n2, int &sum, int &diff); void calcSumAndDiff(int n1, int n2, int &sum, int &diff) { sum = n1 + n2; diff = n2 - n1; } //end of calcSumAndDiff function

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote