Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Let's code a temperature program with C programming! ๐ŸŒก๏ธ
Play lesson

C tutorial for beginners โš™๏ธ - Let's code a temperature program with C programming! ๐ŸŒก๏ธ

4.0 (0)
13 learners

What you'll learn

This course includes

  • 6.5 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#coding #programming #cprogramming // TEMPERATURE CONVERSION PROGRAM char choice = '\0'; float fahrenheit = 0.0f; float celsius = 0.0f; printf("Temperature Conversion Program\n"); printf("C. Celsius to Fahrenheit\n"); printf("F. Fahrenheit to Celsius\n"); printf("Is the temp in Celsius (C) or Fahrenheit (F)?: "); scanf("%c", &choice); if(choice == 'C'){ printf("Enter the temperature in Celsius: "); scanf("%f", &celsius); fahrenheit = (celsius * 9 / 5) + 32; // C to F printf("%.1f Celsius is equal to %.1f Fahrenheit\n", celsius, fahrenheit); } else if(choice == 'F'){ printf("Enter the temperature in Fahrenheit: "); scanf("%f", &fahrenheit); celsius = (fahrenheit - 32) * 5 / 9; printf("%.1f Fahrenheit is equal to %.1f Celsius\n", fahrenheit, celsius); } else{ printf("Invalid choice! Please select C or F\n"); } return 0;

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere