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 - C Tutorial
From the course: Complete Guide to C Programming Foundations
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
-
-
-
-
-
Working with math operators3m 13s
-
(Locked)
Challenge: Do some math50s
-
(Locked)
Solution: Do some math1m 47s
-
(Locked)
Using assignment operators1m 49s
-
(Locked)
Obeying the order of precedence3m 14s
-
(Locked)
Challenge: Get the order correct55s
-
(Locked)
Solution: Get the order correct1m 37s
-
(Locked)
Working with relational operators3m 48s
-
(Locked)
Using logical operators3m 58s
-
(Locked)
Understanding bitwise operators3m 44s
-
(Locked)
Shifting bits3m 13s
-
(Locked)
Exploring unary operators3m 3s
-
Chapter challenge: More math1m 8s
-
(Locked)
Chapter solution: More math2m 45s
-
-
-
-
-
-
-
-
-