C语言程序实验报告--谭浩强(7)

2019-02-16 01:16

#define M 10 main() {

float a[M]; ...... }

该程序正确。

E、#include #define M 10 #define N 2 main() {

float a[M+N]; }

该程序正确。

(2) 运行下面的C语言程序。运行结果可以说明什么问题? #include

main() { int num[5]={1,2,3,4,5,}; int i; for(i=0;i<5;i++) printf(\}

运行结果:

(3) 请上机运行这个程序,指出它的功能和运行结果。 #include char s[]={ '\\t', '0', '\\n', '|', ';', '\\n', '\\n', '/', '*', '\\n',

(213 lines deleted) 0

31

}; /*

*The string is a

* representation of the body * of this program from '0' * to the end */ main() {

int i ; printf(\ for(i=0;s[i];i++) printf(\ printf(\}

功能:以 int 和 string 形式输出同一个数组。从输出结果可以知道给同一个数组定义不同的类型将会输出不同的结果。 输出结果:

实验14

1..实验目的与要求

熟悉指针的正确用法。

5. 实验内容与步骤

(1) 调试下面程序,指出出现错误的原因。 main() {

32

int x=10,y=5,*px,*py; px=py; px=&x; py=&y;

printf(\}

调试结果: #include main() { int x=10,y=5,*px,*py; px=py; px=&x; py=&y; printf(\}

运行结果:

第一个程序错误原因:缺少“#include”。(2)下面程序试图有如下运行结果。 Which style you want to: Capital(c) or uncapital(u);c COMPUTER

Which style you want to: Capital(c) or uncapital(u);u Computer

调试下面程序使其有如上执行结果 #include main() { char *s; char c; printf(\ printf(\ c=getchar(); if(c='c') strcpy (s,\ else strcpy(s,\ put(s); }

错误信息:

33

调试后程序: #include main() { char *s[8]; char c; printf(\ printf(\ c=getchar(); if(c='c') strcpy (s,\ if(c='u') strcpy (s,\ puts(s); }

运行结果:

(2) 调试下面程序。 #include main() {

float a; float*pa

scanf(\printf(\pa=&a;

scanf(\ printf(\}

调试后:

#include main()

34

{

float a; float*pa;

scanf(\printf(\pa=&a;

scanf(\ printf(\printf(\printf(\printf(\

printf(\} 运行结果:

(3) 调试下面程序。 #include main() {

float a,b;

float*pa=&a,*pb=&b;

printf(\printf(\printf(\printf(\}

错误信息:

调试后程序: #include main() {

float a,b;

float*pa=&a,*pb=&b;

printf(\printf(\

35


C语言程序实验报告--谭浩强(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2016年上半年小学《教育教学知识与能力》真题及答案 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: