C bootcamp · Lab 45

Fahrenheit from Celsius

easyMath8 minLesson: Math

Read the question, write C on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

Read a Celsius temperature (integer) and print Fahrenheit using F = C * 9 / 5 + 32.

Use integer arithmetic.

Input. One integer C.

Output. One integer F.

Examples

Example 1
Input
0
Output
32
Example 2
Input
100
Output
212
Hint
  1. printf("%d\n", c * 9 / 5 + 32);
Show correct code

Peek only after you have tried. You can still Check your own version.

#include <stdio.h>

int main(void) {
  int c;
  if (scanf("%d", &c) != 1) return 1;
  printf("%d\n", c * 9 / 5 + 32);
  return 0;
}
main.cC17 · gcc · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.