C语言题库

2026/1/27 6:43:27

#include void yesno(char ch) { switch (ch) { case 'Y': case 'y':cout<<\ break ; case 'N': case 'n':cout<<\ break ; } }

void main() {char ch;

cout<<\请输入一个字母'Y','y'或'n','N':\cin>> ch ; yesno(ch); }

8、以下程序的运行结果是 9 。 #include int a=5;int b=7; plus(int x,int y)

{int z;z=x+y;return z; }

void main() { int a=4,b=5;cout<

9、以下程序的功能是 1 2 6 24 120 。 #include int fac(int n)

{static int f=1;f=f*n;return(f); }

void main() { int i;for(i=1;i<=5;i++) cout<

10、以下程序的输出结果是 2 。 #include int m=13;

int fun(int x,int y) { int m=3; return(x*y-m); }

29

void main() { int a=7,b=5; cout<

解:在主函数中调用fun(a,b)时,m=3是内部变量,返回x*y-m=7*5-3=32。然而主函数中m是外部变量,m=13,所以程序的输出结果(32/13的结果值)为:2。 11、以下程序的执行结果是 4 4 。 #include void func(int ); void main() { int k=4; func(k); func(k); }

void func(int a) { int m=0; m=m+a; cout<

12、以下程序的执行结果是 a=10,b=3 。 #include int a,b; void main() { int swap(); a=3;b=10; swap(); cout<<\}

swap() { int temp; temp=a; a=b; b=temp; }

13、以下程序的执行结果是 x=4 。 #include int x; sub()

30

{ x=4; }

void main() { sub(); cout<<\}

14、以下程序的执行结果是 a=5 a*a=25 a*a*a=8。#include int a=5; void p1(); void p2(); void main() { cout<<\ p1(); p2(); }

void p1() { cout<<\ a=2; }

void p2() { cout<<\}

15、以下程序的执行结果是1.x=3 2.x=6 3.x=1 4.x=3。

#include int x=5; void p1(); void p2(); void main() { int x=3; cout<<\ p1(); p2();

31

cout<<\}

void p1() { x=x+1; cout<<\}

void p2() { int x=1; cout<<\}

16、以下程序的运行结果是 max is 2 。 #include int max(int x,int y); void main() { int a=1,b=2,c; c=max(a,b); cout<<\}

int max(int x,int y) { int z; z=(x>y)?x:y; return(z); }

17、以下程序的运行结果是 10 20 40 40 。 #include int x1=30,x2=40; void sub(int x,int y) { x1=x; x=y; y=x1; return; }

void main() { int x3=10,x4=20; sub(x3,x4); sub(x2,x1); cout<

32


C语言题库.doc 将本文的Word文档下载到电脑
搜索更多关于: C语言题库 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

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