I was told that when returning a value from a function, you can only return one. So why does this code work? And can you explain what happens in the functions? thanks
Their is a structure called Distance that includes distances in feet and inches. the user enters 2 distances (feet,inches) and stores them in 2 type Distance variables. then this function is involked to return the larger of the 2 Distances;
Code:Distance bigengl(Distance dd1, Distance dd2) { if(dd1.feet > dd2.feet) //if feet are different, return return dd1; // the one with the largest feet if(dd1.feet > dd2.feet) return dd2; if(dd1.inches > dd2.inches) //if inches are different, return dd1; //return one with largest else //inches, or dd2 if equal return dd2; }



LinkBack URL
About LinkBacks



