
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write Temperature Conversion Table Using Function
Temperature conversion is nothing but converting Fahrenheit temperature to Celsius or Celsius to Fahrenheit.
In this programming, we are going to explain, how to convert the Fahrenheit temperature to Celsius temperature and how to represent the same in the form of the table by using a function.
Example
Following is the C program for temperature conversion −
#include<stdio.h> float conversion(float); int main(){ float fh,cl; int begin=0,stop=300; printf("Fahrenheit \t Celsius
");// display conversion table heading printf("----------\t-----------
"); fh=begin; while(fh<=stop){ cl=conversion(fh); //calling function printf("%3.0f\t\t%6.lf
",fh,cl); fh=fh+20; } return 0; } float conversion(float fh) //called function{ float cl; cl= (fh - 32) * 5 / 9; return cl; }
Output
When the above program is executed, it produces the following result −
Fahrenheit Celsius ---------- ----------- 0 -18 20 -7 40 4 60 16 80 27 100 38 120 49 140 60 160 71 180 82 200 93 220 104 240 116 260 127 280 138 300 149
In a similar way, you can write the program for converting Celsius to Fahrenheit
By simply changing the equation to
Fahrenheit = (Celsius* 9 / 5) + 32.
Advertisements