- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write the temperature conversion table by 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.
- Related Articles
- How to write PHP script by using ORDER BY clause inside it to sort the data of MySQL table?
- How to write PHP script by using LIKE clause inside it to match the data from MySQL table?
- How to write a MySQL stored function that updates the values in a table?
- Update MySQL table column by matching date using date() function?
- How to write a MySQL stored function that inserts values in a table?
- PHP – Set the current setting for character encoding conversion using iconv_set_encoding() function
- Adding items to table using function in SAP
- How to write the plot title in multiple lines using plot function in R?
- DNA to RNA conversion using JavaScript
- Write C program using isupper() function
- Creating a Function module in ABAP to take any table and write it to the screen
- Write a Python program to perform table-wise pipe function in a dataframe
- How to return table from MySQL function?
- Decimal to Binary conversion using C Programming
- Write a power (pow) function using C++

Advertisements