Temperature Macros

Medium

Define two fully parenthesized function-like macros above main: CELSIUS_TO_F(c), which converts Celsius to Fahrenheit as ((c) * 9.0 / 5.0) + 32.0 with the whole body in one more pair of parentheses, and MAX2(a, b), which yields the larger of its two arguments with ?:. Read two Celsius temperatures with one guarded scanf ("%lf %lf"); on bad input print "invalid input" and return 1. Convert each temperature exactly once into a variable, then print both Fahrenheit values and the warmer of the two, each to one decimal place. Passing the converted variables, not nested macro calls with side effects, to MAX2 is the point of the exercise.

Success Criteria

Your code must pass 3 test case(s) to complete this exercise. 3 hint(s) are available if you need help.

How did you find this exercise?

Your rating helps us improve the content.

Sign in to track your progress

You can work on exercises as a guest, but sign in to track your progress and save your submissions.

This platform is built by its community

Every lesson, project, and tool on HelloC++ is funded by sponsors. Join them and help shape what we build next.

Become a Patron