C语言实验一到实验八答案.doc

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C语言实验一到实验八答案

实验一: 1、录入如下C源程序:  main( )  { printf(This is a C Program\n)  printf(I am a student\n);  }main() {printf(This is a C Program\n); printf(I am a student\n); } 2、编写一个C程序,第一行显示你的名字,第二行显示你所在的街道地址,第三行显示你所在的城市和邮政编码。#include stdio.h int main() { printf(Joe Smith); printf(\n99 Somewhere Street); printf(\nNonesuch, N.J., 07030); return 0; } 3、编写一个C程序,输出以下信息: **************************** Hello,World! **************************** #includestdio.h main() { printf(***********************\n); printf( Hello, World!\n); printf(***********************\n); } 4、编程序,输出如下图形: * * ** ** *** *** ******** #includestdio.h main() { printf(* *\n); printf(** **\n); printf(*** ***\n); printf(********\n); } 5、遵循良好的编程习惯重新编写下列程序 #includestdio.h int main( ){ printf ( “The time has come” ); } #includestdio.h int main() {printf(The time has come); } 6、输入以下程序,查找错误并改正,输出正确的运算结果 #includestdio.h void main() {int a,b a=123;b=456; sum=a+b print(sum is %d\n,sum); } #includestdio.h void main() {int a,b,sum; a=123;b=456; sum=a+b; printf(sum is %d\n,sum); } 7、编写一个C程序,显示表达式3.0*5.0,7.1*8.3-2.2和3.2/(6.1*5)的结果。#include stdio.h int main() { printf ( 3.0 * 5.0 = %f\n, 3.0 * 5.0 ); printf ( 7.1 * 8.3 - 2.2 = %f\n, 7.1 * 8.3 - 2.2 ); printf ( 3.2 / (6.1 * 5) = %f\n, 3.2 / (6.1 * 5) ); return 0; } 实验二: 1、编写程序,在程序中定义a=5,b=7,c=71,x=31.19,y=-31.2 实现下面的输出格式和结果(U表示空格): a=U5,b=U7,a-b=-2,c=U71% x=31.19,y=U-31.2,z =-31.2U,k=31.1900 #includestdio.h main() {int a=5,b=7,c=71; float x=31.19,y=-31.2,z,k; printf(\na=%2d,b=%2d,a-b=%d,c=%3d%%\n,a,b,a-b,c); printf(x=%5.2f,y=%6.1f,z=%-6.1f,k=%.4f,x,y,y,x); } 2、编写程序,显示下面的提示: Enter the length of the room: Enter the width of the room: 在显示每个后,你的程序应该使用scanf()函数调用为所显示的提示接受来自键盘的数据。在输入长度和宽度后,程序应该计算和显示面积。#includestdio.h main() {float l,w,a; printf(\nEnter the length of the room:\n); scanf(%f,l); printf(\nEnter the width of the room:\n); scanf(%f,w); a=l

文档评论(0)

zhuliyan1314 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档