1-1 在你自己的系统中运行 "hello, world" 程序. 再有意去掉程序中的部分内容, 看看会得到什么错误信息.
#include <stdio.h>
int
main()
{
printf("hello, world\n");
return 0;
}
输出了 (后面一行是 Code::Blocks 加的, 很不错哈
):
引用
hello, world
Process returned 0 (0x0) execution time : 0.055 s
我把
#include <stdio.h>
删除了, 编译通过, 有个警告, 可以运行.
1-2 做个试验, 当 printf 函数的参数字符串中包含 \c (其中 c 是上面的转义字符序列中未曾列出的某一字符) 时, 观察一下会出现什么情况.
编译时出现一个警告, 字符直接输出了, 不包含 "\" .
1-3 修改温度转换程序, 使之能在转换表的顶部打印一个标题.
#include <stdio.h>
int
main()
{
float fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
printf("F:\tC:\n");
fahr = lower;
while (fahr <= upper) {
celsius = (5.0/9.0) * (fahr - 32.0);
printf("%3.0f\t%6.1f\n", fahr, celsius);
fahr += step;
}
return 0;
}
1-4 编写一个程序打印摄氏度转换为相应华氏温度的转换表.
#include <stdio.h>
int
main()
{
float celsius, fahr;
int lower, upper, step;
lower = 0;
upper = 30;
step = 2;
printf("C:\tF:\n");
celsius = lower;
while (celsius <= upper) {
fahr = ((9.0/5.0) * celsius) + 32.0;
printf("%6.1f\t%3.0f\n", celsius, fahr);
celsius += step;
}
return 0;
}
输出:
引用
C: F:
0.0 32
2.0 36
4.0 39
6.0 43
8.0 46
10.0 50
12.0 54
14.0 57
16.0 61
18.0 64
20.0 68
22.0 72
24.0 75
26.0 79
28.0 82
30.0 86
1-5 修改温度转换程序, 要求以逆序 (即按照从 300 度到 0 度的顺序) 打印温度转换表
#include <stdio.h>
int
main()
{
float fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
printf("F:\tC:\n");
fahr = upper;
while (fahr > lower) {
celsius = (5.0/9.0) * (fahr - 32.0);
printf("%3.0f\t%6.1f\n", fahr, celsius);
fahr -= step;
}
return 0;
}
分享到:
相关推荐
Some Final Comments on the MOV Instructions<br><br>4.9 Laboratory Exercises<br>4.9.1 The UCR Standard Library for 80x86 Assembly Language Programmers<br>4.9.2 Editing Your Source Files<br>4.9.3 The ...
<br>Published by Prentice-Hall in 1988 <br><br>ISBN 0-13-110362-8 (paperback)<br>ISBN 0-13-110370-9 <br><br>Contents<br>Preface <br>Preface to the first edition <br>Introduction <br>Chapter 1: A ...
够权威<br><br>Brian W.Kernighan && Dennis M.Ritchie
The ANSI C Programming Language (Kernighan & Ritchie) EN 英文原版<br><br>学习标准C语言最好的入门书,结合Unix高级编程,将C语言讲得非常透彻<br>Chapter 1- A Tutorial Introduction<br>Chapter 2- Types,...
The C programming Language By Brian W. Kernighan and Dennis M. Ritchie. Published by Prentice-Hall in 1988 ISBN 0-13-110362-8 (paperback) ISBN 0-13-110370-9 目录结构: Contents Preface Preface ...
<The C Programming Language中文译本>
Beginning Transact-SQL with SQL ...Appendix C - System Stored Procedure Reference <br> Appendix D - Information Schema Views Reference <br> Appendix E - Answers to Exercises <br> Index <br>第三部分 of 5
《the c programming language》第6单元课本程序《the c programming language》第6单元课本程序《the c programming language》第6单元课本程序《the c programming language》第6单元课本程序《the c programming ...
Chapter 3 - Tools for Accessing SQL Server <br> Chapter 4 - Introducing Transact-SQL Language <br> Chapter 5 - Data Retrieval <br> Chapter 6 - SQL Functions <br> Chapter 7 - Aggregation and Grouping ...
Chapter 3 - Tools for Accessing SQL Server <br> Chapter 4 - Introducing Transact-SQL Language <br> Chapter 5 - Data Retrieval <br> Chapter 6 - SQL Functions <br> Chapter 7 - Aggregation and Grouping ...
中文版 Apple 官方 Swift 教程《The Swift Programming Language》
最经典的c语言教程,不用多介绍了吧,The C Programming Language, The C Programming Language, K&C, 发明人写的。
Oracle---Fundamentals of the Java Programming Language, Java SE 6 Ed 1 课程学习文档
---------------------------------<br>Section 1: The Basics<br> chap1-Getting Started<br> chap2-An Introduction to Unicode<br> chap3-Windows and Messages<br> chap4-An Exercise in Text Output<br> chap5-...
The C Programming Language[C程序设计语言] -- (英文第2版) -- B.W.Kernighan & D.M.Ritchie 著.pdf
The Objective-C language is a simple computer language designed to enable sophisticated object-oriented programming. Objective-C is defined as a small but powerful set of extensions to the standard ...
《the c programming language》第1单元课后练习《the c programming language》第1单元课后练习《the c programming language》第1单元课后练习《the c programming language》第1单元课后练习
《the c programming language》第4单元课本程序《the c programming language》第4单元课本程序《the c programming language》第4单元课本程序《the c programming language》第4单元课本程序《the c programming ...
Problem - Design - Solution 第二部分<br>Table of Contents <br> ASP.NET 2.0 Website Programming—Problem - Design - Solution <br> Foreword <br> Introduction <br> Chapter 1 - Introducing the Project: ...
《the c programming language》第7单元课后答案《the c programming language》第7单元课后答案《the c programming language》第7单元课后答案《the c programming language》第7单元课后答案《the c programming ...