Dotcpp  >  试卷列表  >  C语言中用户标识符的作用域和存储类

C语言中用户标识符的作用域和存储类


第1题

在一个C源程序文件中所定义的全局变量,其作用域为

共 1 分 

第2题

以下叙述中正确的是( )。 

共 1 分 

第3题

以下叙述中正确的是( )。 

共 1 分 

第4题

在C语言中,只有在使用时才占用内存单元的变量,其存储类型是 ( )。

共 1 分 

第5题

当没有指定C语言中函数形参的存储类别时,函数形参的存储类别 是( )。 

共 2 分 

第6题

以下叙述错误的是( )。 

共 2 分 

第7题

以下选项中叙述错误的是( )。

共 4 分 

第8题

设函数中有整型变量n,为保证其在未赋值的情况下初值为0,应选 择的存储类别是( )。 

共 4 分 

第9题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
int sum(int *array,int len)
{
 if(len == 0)
 return array[0];
 else
 return array[0]+sum(array+1,len-1);
}
main()
{
 int i=1,j=3;
 printf("%d,",i++);
 {
 int i = 0;
 i+=j*2;
 printf("%d,%d,",i,j);
 }
 printf("%d,%d\n",i,j);
}

程序运行后的输出结果是( )。 

共 4 分 

第10题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
int f(int n)
{
 int t=0,a=5;
 if(n/2)
 {
 int a=6;
 t+=a++;
 }
 else
 {
 int a=7;
 t+=a++;
 }
 return t+a++;
}
main()
{
 int s=0,i=0;
 for(;i<2;i++)s+=f(i);
 printf("%d\n",s);
}

程序运行后的输出结果是( )。 

共 4 分 

第11题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
void fun(int n)
{
 static int num = 1;
 num=num+n;
 printf("%d", num);
}
main()
{
 fun(3);
 fun(4);
 printf("\n");
}

程序运行后的输出结果是( )。 

共 4 分 

第12题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
int f(int m)
{
 static int n=0;
 n+=m;
 return n;
}
main()
{
 int n=0;
 printf("%d",f(++n));
 printf("%d\n",f(n++)); }

程序运行后的输出结果是( )。 

共 4 分 

第13题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
int fun()
{
 static int x=1;
 x*=2;
 return x;
}
main()
{
 int i,s=1;
 for(i=1;i<=2;i++)s=fun();
 printf("%d\n",s);
}

程序运行后的输出结果是( )。 

共 4 分 

第14题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
int fun()
{
 static int x=1; x*=2;
 return x;
}
main()
{
 int i,s=1;
 for(i=1;i<=3;i++)s*=fun();
 printf("%d\n",s);
}

程序运行后的输出结果是( )。 

共 4 分 

第15题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
int fun()
{
 static int x=1;
 x+=1;
 return x;
}
main(){
 int i,s=1;
 for(i=1;i<=5;i++)s+=fun();
 printf("%d\n",s);
}

程序运行后的结果是( )。

共 4 分 

第16题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
int f(int n);
main()
{
 int a=3,s;
 s=f(a);
 s=s+f(a);
 printf("%d\n",s);
}
int f(int n)
{
 static int a=1;
 n+=a++; return n;
}

程序运行以后的输出结果是( )。 

共 4 分 

第17题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
int fun(int x,int y)
{
 static int m=0,i=2;
 i+=m+1;
 m=i+x+y;
 return m;
}
main()
{
 int j=1,m=1,k;
 k=fun(j,m);
 printf("%d,",k);
 k=fun(j,m);
 printf("%d\n",k);}

执行后的输出结果是( )。 

共 4 分 

第18题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
int fun(int a,int b)
{
 static int m=0,i=2;
 i+=m+1;
 m=i+a+b;
 return m;
}
main()
{
 int k=4,m=1,p;
 p=fun(k,m);
 printf("%d,",p);
 p=fun(k,m);
 printf("%d\n",p);
}

程序运行后的输出结果是( )。

共 4 分 

第19题

有以下程序

1
2
3
4
5
6
7
8
#includeint fun(int x[],int n)
{
 static int sum=0,i;
 for(i=0;i<n;i++)sum+=x[i]; retur num;}
main()
int a[] {1,2,3,4,5},b[]={6,7,8,9},s=0;
 s=fun(a,5)+fun(b,4);
printf("%d\n",s);}

程序执行后的输出结果是( )。 

共 4 分 

第20题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
int fun(int n)
{
 static int t=1;
 int i=1;
 for(;i<=n;i++)t*=i;
 return t;
}
main()
{
 int t=1,i;
 for(i=2;i<4;i++)
 t+=fun(i);
 printf("%d\n",t);
}

程序的运行结果是( )。 

共 4 分 

第21题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
int sum(int data)
{
 static int init=1;
 return init+=data;
}
main()
{
 int i;
 for(i=1;i<=1;i++)printf("%d,",sum(i));
 printf("\n");
}

程序运行后的输出结果是( )。 

共 4 分 

第22题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
int sum(int data)
{
 static int init=0;
 return init+=data;
}
main()
{
 int i;
 for(i=1;i<=5;i++)printf("%d,",sum(i));
 printf("\n");
}

程序运行后的输出结果是( )。 

共 4 分 

第23题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
int *sum(int data)
{
 static int init=0;
 init+=data;
 return &init;
}
main()
{
 int i,*p;
 for(i=1;i<=4;i++) sum(i);
 p=sum(0);
 printf("%d\n",*p);
}

程序运行后的输出结果是( )。

共 4 分 

第24题

以下针对全局变量的叙述错误的是( )。 

共 4 分 

第25题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
void fun2(char a,char b)
{
 printf("%c %c",a,b);
}
char a='A',b='B';
void fun1()
{
 a='C';
 b='D';
}
main()
{ fun1();
 printf("%c %c ",a,b); 
 fun2('E','F');
}

程序的运行结果是( ) 

共 4 分 

第26题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
int b=2;
int fun(int *k)
{
 b=*k+b;
 return(b);
}
main()
{
 int a[10]={1,2,3,4,5,6,7,8},i;
 for(i=2;i<4;i++)
 {
 b=fun(&a[i])+b;
 printf("%d",b); }
 printf("\n");
}

程序运行后的输出结果是( )。

共 4 分 

第27题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
int a=1,b=2;
void fun1(int a,int b)
{
 printf("%d%d",a,b);
}
void fun2()
{
 a=3;
 b=4;
}
main()
{
 fun1(5,6); fun2();
 printf("%d%d\n",a,b); 
}

程序运行后的输出结果是( )。 

共 4 分 

第28题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
int a=2; 
int f()
{
 static int n; 
 int m; 
 m=n=0; 
 n++;
 a++;
 m++;
 return m+n+a; 
}
main()
int k; 
 for(k=0;k<3;k++)
 printf("%d, ",f());
 printf("\n"); 
}

程序的运行结果是( )。 

共 4 分 

第29题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
int a=4;
int f(int n)
{
 int t=0;
 static int a=5;
 if(n%2)
 {
 int a=6;
 t+=a++;
 else
 {
 int a=7;
 t+=a++;
 }
 return t+a++;
}
main()
{
 int s=a,i=0;
 for(;i<2;i++)s+=f(i);
 printf("%d\n",s);
}

程序运行后的输出结果是( )。 

共 4 分