struct rec {
int length;
int breath;
};
int area(rec objrec1) {
objrec1.length ++;
//objrec1.breath;
//int result= objrec1.length++ * objrec1.breath;
return(objrec1.length++ * objrec1.breath);
//return(result);
}
int main() {
rec objrec = { 10,5 }; // create object to access struct
int arearesult;
arearesult = area(objrec); // we pass the whole struct into the parameter
cout << arearesult << endl;
}
my question is, if actual parameter is not making changes on the formal parameter, how is it that the increment of length (++) when returned to the main "arearesult" affected the outcome making the answer 55 instead of 50. because I'm thinking if when I incremented length by 1 making it 11,but when it gets to the main() it will become invalid and turn back to 10 since length in the actual and formal parameter are not the same. Thanks