模拟试题

3773考试网计算机等级考试模拟试题正文

C语言程序设计模拟五

来源:fjzsksw.com 2010-5-24 8:50:47

 

【程序43】
题目:学习使用static的另一用法。   
1.程序分析:
2.程序源代码:
#include "stdio.h"
main()
{
int i,num;
num=2;
for(i=0;i<3;i++)
{
printf("\40: The num equal %d \n",num);
num++;
{
static int num=1;
printf("\40:The internal block num equal %d\n",num);
num++;
}
}
}
-----------------------------------------------------------------------------
【程序44】
题目:学习使用external的用法。
1.程序分析:
2.程序源代码:
#include "stdio.h"
int a,b,c;
void add()
{ int a;
a=3;
c=a+b;
}
void main()
{ a=b=4;
add();
printf("The value of c is equal to %d\n",c);
}
-----------------------------------------------------------------------------
【程序45】
题目:学习使用register定义变量的方法。
1.程序分析:
2.程序源代码:
void main()
{
register int i;
int tmp=0;
for(i=1;i<=100;i++)
tmp+=i;
printf("The sum is %d\n",tmp);
}
-----------------------------------------------------------------------------
【程序46】
题目:宏#define命令练习(1)   
1.程序分析:
2.程序源代码:
#include "stdio.h"
#define TRUE 1
#define FALSE 0
#define SQ(x) (x)*(x)
void main()
{
int num;
int again=1;
printf("\40: Program will stop if input value less than 50.\n");
while(again)
{
printf("\40lease input number==>");
scanf("%d",&num);
printf("\40:The square for this number is %d \n",SQ(num));
if(num>=50)
  again=TRUE;
else
  again=FALSE;
}
}

 

上一页  [1] [2] [3] [4] 下一页

触屏版 电脑版
3773考试网 琼ICP备12003406号-1