/* Rewrite the temperature conversion program of Section 1.2 to use a function for conversion. */

#include <stdio.h>

float celsius(float fahr);

/* print Fahrenheit-Celsius table or fahr = 0, 20, ..., 300; floating-point version */
main()
{
float fahr;
int lower, upper, step;
lower = 0; /* lower limit of temperature table */
upper = 300; /* upper limit */
step = 20; /* step size */
fahr = lower;
while(fahr <= upper)
{
printf("%3.0f %6.1f\n", fahr, celsius(fahr));
fahr += step;
}
} /* celsius: convert fahr into celsius */
float celsius(float fahr)
{
return (5.0 / 9.0) * (fahr - 32.0);
}

C - The C Answer (2nd Edition) - Exercise 1-15的更多相关文章

  1. C - The C Answer (2nd Edition) - Exercise 1-7

    /* Write a program to print the value of EOF. */ #include <stdio.h> main() { printf("EOF ...

  2. C - The C Answer (2nd Edition) - Exercise 1-2

    /* Experiment to find out what happens when printf's argument string contains \c, where c is some ch ...

  3. C - The C Answer (2nd Edition) - Exercise 1-1

    /* Run the "hello, world" program on your system. Experiment with leaving out parts of the ...

  4. C - The C Answer (2nd Edition) - Exercise 1-16

    /* Revise the main routine of the longest-line program so it will correctly print the length of arbi ...

  5. C - The C Answer (2nd Edition) - Exercise 1-8

    /* Write a program to count blanks, tabs, and newlines. */ #include <stdio.h> /* count blanks, ...

  6. C - The C Answer (2nd Edition) - Exercise 1-5

    /* Modify the temperature conversion program to print the table in reverse order, that is, from 300 ...

  7. C - The C Answer (2nd Edition) - Exercise 1-12

    /* Write a program that prints its input one word per line. */ #include <stdio.h> #define IN 1 ...

  8. C - The C Answer (2nd Edition) - Exercise 1-4

    /* Write a program to print the corresponding Celsius to Fahrenheit table. */ #include <stdio.h&g ...

  9. C - The C Answer (2nd Edition) - Exercise 1-6

    /* Verify that the expression getchar() != EOF is 0 or 1. */ #include <stdio.h> main() { int c ...

随机推荐

  1. Statement和PreparedStatement深入学习总结

    最近在看java安全编码方面的书籍,在看到SQL注入漏洞的问题时,引发了我对Statement和PreparedStatement深入总结的欲望,废话少说,下面咱们就正式开始. 当初始的SQL查询被修 ...

  2. sql server truncate table 删除表数据限制条件

    truncate 注释 注释TRUNCATE TABLE 在功能上与不带 WHERE 子句的 DELETE 语句相同:二者均删除表中的全部行.但 TRUNCATE TABLE 比 DELETE 速度快 ...

  3. 获取WebBrowser全cookie 和 httpWebRequest 异步获取页面数据

    获取WebBrowser全cookie [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true) ...

  4. Detectron-MaskRCnn:Mask判别和获取前向Mask的标签

    对于FCN-SceneParse网络,最后卷积生成N个类别的maps,每个Map都得到图像所有点的单类概率.MaskRCNN的结构与FCN不相同. 参考三个文章: Detectron总结1:Blob的 ...

  5. (转)版本管理工具介绍——SVN篇(二)

    http://blog.csdn.net/yerenyuan_pku/article/details/72620498 上一篇文章我介绍了一下SVN,以及SVN服务器的安装,相信大家都安装了,接下来我 ...

  6. OpenGL坐标系之间的转换 http://blog.csdn.net/sac761/article/details/52179585

    1. OpenGL 渲染管线 OpenGL渲染管线分为两大部分,模型观测变换(ModelView Transformation)和投影变换(Projection Transformation).做个比 ...

  7. java基础学习之垃圾回收机制

    回收过程: 1.发现无用的对象 2.回收无用对象占用的内存的空间. 垃圾回收相关算法: 1.引用计数法 堆中每个对象都有一个引用计数.被引用一次,计数加一.被引用变量值变为null,则计数减一. 到计 ...

  8. 08Java Server Pages 语法

    Java Server Pages 语法 基础语法 注释 <!--   -->可以在客户端通过源代码看到:<%--   --%>在客户端通过查看源代码看不到. <!--浏 ...

  9. 04Microsoft SQL Server 数据库创建,查看,使用,修改及删除

    Microsoft SQL Server 数据库创建,查看,使用,修改及删除 创建数据库 创建普通数据库 USE [master] GO CREATE DATABASE [MyDataBase] -- ...

  10. freemarker使用map替换ftl中相关值

    ftl文件demo01.ftl <html> <head> <title>Welcome!</title> </head> <body ...