From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Chapter solution: More math

Chapter solution: More math

(upbeat music) - [Instructor] For this exercise, the printf statements follow a specific pattern, I'll write the first one, and then I can copy and paste to quickly build the rest. Format using the %d placeholders for variable values A and B, and then the expression to add them, A + B. The two variables are the second and third arguments with the math expression coming last. Now I can copy and paste this basic format six times for the other six output statements, matching their appropriate operators. For subtraction, change the character and then the operator right here. Ditto for multiplication and division. But wait a second, keep in mind that division may require a real number, so typecast the expression as a float. And because it could be a floating point value, change this placeholder to an f. This might be something that you forgot in your solution. Moving on, modulus operator. And something else you might've forgotten in your solution is that percent signs must be specified…

Contents