- 2
- 0
- 约 14页
- 2016-12-29 发布于北京
- 举报
§类型修饰符及输入输出的实现 授课班级: 授课时间: *.基本类型修饰符 类型修饰符修饰整型的情况(P19) 活动:分析下面程序运行结果 main( ) { int x1,y1; long x2,y2; x1=32767;y1=32769; x2=32767L;y2=32769L; printf(″x1=%d,x2=%ld\ny1=%d,y2=%ld″,x1,x2,y1,y2); } 2.输入输出实现及其函数应用 说明: ?C语言中,输入输出是由函数库提供的,这些输入、输出函数包含在头文件stdio.h中; ?在使用输入输出函数时,一般要在程序最前面加上#include stdio.h,或#include ”stdio.h” 活 动 编一个小程序,应用字符输入输出函数实现一个字符的输入和输出 作业 P35: P37: * * 任课教师: Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 复习上次内容 1.找出哪些是合法的整型常量:045、0x89g、90、078、0x11f 2.找出哪些是非法的实型常量:0.45、0x6.7、e9、0.7e0.2 3.找出哪些是合法的字符常量:`9`、 `\056` 、 `\x11` `\\`、 `` 4.说出float与double及字符型数据各占几个字节内存单元? 5.说出相关ASCII码值 6.说出字符串常量”how”占几个字节的内存单元? Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 回顾(课本P15) 基本的类型修饰符 signed(有符号) unsigned(无符号) long(长型) short(短型) Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 说明1:基本类型修饰符主要用于修饰int型数据 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 说明2 当类型修饰符独自使用时,则认为是修饰int型的。因此,下面几种类型修饰符是等效的:(见书P21) 修 饰 符 等 效 于 signed signed int或int unsigned unsigned int long long int short short int 说明3 当要表示某个整型常数为常整型时,可直接在该数后面加“L”。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 运行结果 x1=32767,x2=32767 y1=-32767,y2=32769 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. 格式输出函数:printf() 格式输入函数:scanf() 不过,scanf()与printf()函数可不要! Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. printf函数:格式输出函数 格
原创力文档

文档评论(0)