return (f2(a)+f2(b)+f2(c)); }
long f2(int x) { int m; m=x*x; return (m); }
实验12
1..实验目的与要求
掌握如何正确地使用变量的存储属性。 2.实验准备
阅读并分析下面的实验内容。 3. 实验内容和步骤
(1) 分析下面的C语言程序,找出其中的错误,并分析原因。/***file.c***/ int last(void); int new(int); int resert(void); extern int i=1; main (void) { int i,j; i=reset(); for(j=1;j<=3;j++) { printf(\ printf(\ printf(\
printf(\
26
}
int next(void) { return(i++);
} }
/***file2.c***/ static int i=10; fast(void) {return(i-=1);} new(int i) { static int j=5; return(i=j+=++i);
}
/***file3.c***/ extern int i; reset() {return(i);}
27
(2)给出以下的程序框架,请根据程序框架分析程序的的功能。
/*****file.c*****/ #include
}
/*****file2.c*****/ a() { int x=1;
} int y=2; b() {
static int w=3;
28
} c() { }
/*****file3.c*****/ #include
extern int y; e() { } f() { int v=4;
}
老师:很抱歉!实验12我是真的不会。请谅解!
29
实验13
1..实验目的与要求
(1)掌握数组定义的正确方法。 (2)了解数组元素的存储规律。 2.实验准备
准备下面的实验内容。 4. 实验内容和步骤
(1) 编写程序来测试下面的数组定义是否正确。 A、
#include
scanf(\float a[n]; ....... }
该程序错误:数组的元素个数只能是确定的数目,不可以定义为变量。 B、#include
int n=10;
float a[n]; ...... }
该程序错误:数组的元素个数只能是确定的数目,不可以定义为变量。 C、#include
const int n=10;
float a[n] ...... }
该程序错误:此程序虽然定义了n是一个不可改变的值,但是a[n]中的n只能是确定的正整数。
D、#include
30