Like many of you, I am very new to programming. I love this book, but sometimes I wonder if I missed a paragraph or something. It could just be the teaching technique because when I finally figure out the answer, I feel smart and accomplished. Haha.
Anyway, I thought the triangle challenge had a trick in it- specifically the line: "float angleC = remainingAngle(angleA, angleB);
I though that (angleA, angleB) was supposed to be changed to (angleA + angleB), but in the solutions some of you posted, you didn’t do that. Maybe one of you more experienced programmers can take a look at my solution and tell me what you think. In particular if my solution would cause problem down the line with more complex code or something like that.
Here’s what I did:
float remainingAngle(float twoAngles)
float angle = 180 - twoAngles; return angle;
int main(int argc, const char * argv)
float angleA = 30.0; float angleB = 60.0; float angleC = remainingAngle(angleA + angleB); printf("The third angle is %.2f\n", angleC); return 0;