【c语言基础题】— —第五版,可当作日常练习和期末复习,有奇效哟!

🎯问题:

1. (单选题)【选择题】

有以下程序

#include <stdio.h>

main()

{

int i,j;

for(i=1;i<4;i++)

{

for(j=i;j<4;j++)

printf("%d*%d=%d",i,j,i*j);

printf("\n");

}

}

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

  • A. 1*1=1 1*2=2 1*3=32*2=4 2*3=63*3=9
  • B. 1*1=1 1*2=2 1*3=32*1=2 2*2=43*1=3
  • C. 1*1=11*2=2 2*2=41*3=3 2*3=6 3*3=9
  • D. 1*1=12*1=2 2*2=43*1=3 3*2=6 3*3=9

2. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{ ... while(getchar()!='\n'); ...}

以下叙述中正确的是( )

  • A. 此while语句将无限循环
  • B. getchar()不可以出现在while语句的条件表达式中
  • C. 当执行此while语句时, 只有按回车键程序才能继续执行
  • D. 当执行此while语句时, 按任意键程序就能继续执行

3. (单选题)【选择题】有以下程序

#include<stdio.h>

main()

{

int i,sum;

for(i=1;i<6;i++)

sum+=i;

printf("%d\n",sum);

}

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

  • A. 0
  • B. 随机值
  • C. 15
  • D. 16

4. (单选题)【选择题】

以下程序段中的变量已正确定义:

for(i=0;i<4;i++,i++)

for(k=1;k<3;k++);

printf("*");

程序段的输出结果是( )

  • A. ******
  • B. ****
  • C. **
  • D. *

5. (单选题)【选择题】以下函数按每行8个输出数组中的数据:

void fun(int *w,int n)

{

int i;

for(i=0;i<n;i++)

{

______ printf("%d",w[i]);

}

printf("\n");

}

下画线处应填入的语句是( )

  • A. if(i/8==0)printf("\n");
  • B. if(i/8==0)continue;
  • C. if(i%8==0)printf("\n");
  • D. if(i%8==0)continue;

6. (单选题)【选择题】有以下程序:

#include<stdio.h>

main()

{

int x=23;

do { printf("%2d\n",x--); } while(!x);

}

程序的执行结果是( )

  • A. 输出321
  • B. 输出23
  • C. 不输出任何内容
  • D. 陷入无限循环

7. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{

char c;

do {

c = getchar();

putchar(c);

}while(c!='#');

printf("\n");

}

执行时如输入: abcdefg##<回车>, 则输出结果是( )

  • A. abcdefg#
  • B. abcdefg
  • C. abcdefg##
  • D. ##

8. (单选题)【选择题】若变量已正确定义, 有以下程序段

i=0;

do printf("%d,",i);

while(i++);

printf("%d\n",i);

其输出结果是( )

  • A. 0,1
  • B. 0,0
  • C. 1,1
  • D. 程序进入无限循环

9. (单选题)【选择题】若k是int类型变量, 且有以下for语句:

for(k=-1;k<0;k++)

printf("****\n");

下面关于语句执行情况的叙述中正确的是( )

  • A. 循环体执行一次
  • B. 循环体执行两次
  • C. 循环体一次也不执行
  • D. 构成无限循环

10. (单选题)【选择题】以下不构成无限循环的语句或者语句组是( )

  • A. n=0; do{++n;}while(n<=0);
  • B. n=0; while(1){n++;}
  • C. n=10; while(n); {n--;}
  • D. for(n=0,i=1;i++) n+=i;

11. (单选题)【选择题】若有以下程序

#include<stdio.h>

main()

{

int a=6,b=0,c=0;

for(;a;)

{

b+=a;

a-=++c;

}

printf("%d,%d,%d\n",a,b,c);

}

则程序的输出结果是( )

  • A. 0,18,3
  • B. 1,14,3
  • C. 0,14,3
  • D. 0,14,6

12. (单选题)【选择题】有以下程序:

#include<stdio.h>

main()

{

int sum=0,x=5;

do{sum+=x;}while(!--x);

printf("%d\n",sum);

}

程序的运行结果是( )

  • A. 0
  • B. 5
  • C. 14
  • D. 15

13. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{

int i,a;

for(i=0;i<=10;i++)

a=i;

printf("%d,%d\n",i,a);

}

程序的运行结果是( )

  • A. 11,10
  • B. 10,10
  • C. 10,11
  • D. 11,11

14. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{

char *s="120119110";

int n0,n1,n2,nn,i;

n0=n1=n2=nn=i=0;

do

{

switch(s[i++])

{

default:nn++;

case '0':n0++;

case '1':n1++;

case '2':n2++;

}

}while(s[i]);

printf("n0=%d,n1=%d,n2=%d,nn=%d\n",n0,n1,n2,nn);

}

程序的运行结果是( )

  • A. n0=3,n1=8,n2=9,nn=1
  • B. n0=2,n1=5,n2=1,nn=1
  • C. n0=2,n1=7,n2=10,nn=1
  • D. n0=4,n1=8,n2=9,nn=1

15. (单选题)【选择题】若i和k都是int类型变量, 有以下for语句:

for=(i=0,k=-1;k=1;k++)

printf("* * * * *\n");

下面关于语句执行情况的叙述中正确的是( )

  • A. 循环体执行两次
  • B. 循环体执行一次
  • C. 循环体一次也不执行
  • D. 构成无限循环

16. (单选题)【选择题】以下程序段中, 循环次数不超过10的是( )

  • A. int i=10;do{i=i+1;}while(i<0);
  • B. int i=5;do{i+=1;}while(i>0);
  • C. int i=1;do{i+=2;}while(i!=10);
  • D. int i=6;do{i-=2;}while(i!=1);

17. (单选题)【选择题】以下函数的功能是计算a的n次方作为函数值返回:

double fun(double a,int n)

{

int i;

double s=1.0;

for(i=1;i<=n;i++)

s=______;

return s;

}

为实现上述功能, 函数中下划线处应填入的是( )

  • A. s*i
  • B. s*a
  • C. s+i*i
  • D. s+a*a

18. (单选题)【选择题】有以下程序

#include<stdio.h>

main()

{

int s=0,n;

for(n=0;n<3;n++)

{

switch(s)

{

case 0:

case 1:s+=1;

case 2:s+=2;break;

case 3:s+=3;

default:s+=4;

}

printf("%d,",s);

}

}

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

  • A. 1,2,4,
  • B. 1,3,6,
  • C. 3,10,14,
  • D. 3,6,10,

19. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{

int k,n=0;

char c,str[]="teach";

for(k=0;str[k];k++)

{

c=str[k];

switch(k)

{

case 1:

case 3:

case 5: putchar(c); printf("%d",++n);

break;

default:putchar('N');

}

}

}

程序的运行结果是( )

  • A. Ne1NN
  • B. e1a2e3
  • C. Ne1Nc2N
  • D. Na1NNNN

20. (单选题)【选择题】若变量已正确定义

for(x=0,y=0; (y!=99&&x<4); x++)

则以上for循环( )

  • A. 执行无限次
  • B. 执行3次
  • C. 执行4次
  • D. 执行次数不定

21. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{

char c;

while((c=getchar())!='\n')

{

switch(c-'2')

{

case 0:

case 1:putchar(c+4);

case 2:putchar(c+4);break;

case 3:putchar(c+3);

default:putchar(c+2);break;

}

}

printf("\n");

}

程序运行后从第一列开始输入以下数据:

2473<回车>

程序的输出结果是( )

  • A. 668977
  • B. 4444
  • C. 6677877
  • D. 68766

22. (单选题)【选择题】

有以下程序

#include <stdio.h>

main()

{

int i;

for(i=1;i<=40;i++)

{

if(i++%5==0)

if(++i%8==0)

printf("%d",i);

}

printf("\n");

}

执行后的输出结果是( )

  • A. 32
  • B. 24
  • C. 5
  • D. 40

23. (单选题)【选择题】要求通过while循环不断读入字符, 当读入字母N时结束循环。 若变量已正确定义, 以下正确的程序段是( )

  • A. while((ch=getchar())!='N') printf("%c",ch);
  • B. while(ch=getchar() ='N') printf("%c",ch);
  • C. while(ch=getchar()=='N') printf("%c",ch);
  • D. while((ch=getchar())=='N') printf("%c",ch);

24. (单选题)【选择题】

有以下程序

#include<stdio.h>

main()

{

int i,j,m=55;

for(i=1;i<=3;i++)

for(j=3;j<=i;j++)

m=m%j;

printf("%d\n",m);

}

程序的运行结果是( )

  • A. 1
  • B. 0
  • C. 2
  • D. 3

25. (单选题)【选择题】有以下程序:

#include<stdio.h>

main()

{

int x=8;

for(;x>0;x--)

{

if(x%3)

{

printf("%d,",x--);

continue;

}

printf("%d,",--x);

}

}

程序的运行结果是( )

  • A. 7,4,2,
  • B. 8,7,5,2,
  • C. 9,7,6,4,
  • D. 8,5,4,2,

26. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{

int a=7;

while(a--);

printf("%d\n",a);

}

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

  • A. -1
  • B. 0
  • C. 1
  • D. 7

27. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{

int s;

scanf("%d",&s);

while(s>0)

{

switch(s)

{

case 1:printf("%d",s+5);

case 2:printf("%d",s+4);break;

case 3:printf("%d",s+3);

default:printf("%d",s+1);break;

}

scanf("%d",&s);

}

}

运行时, 若输入1 2 3 4 5 0<回车>, 则输出结果是( )

  • A. 6566456
  • B. 66656
  • C. 66666
  • D. 6666656

28. (单选题)【选择题】在以下给出的表达式中, 与while(E)中的(E)不等价的表达式是( )

  • A. (!E==0)
  • B. (E>0||E<0)
  • C. (E==0)
  • D. (E!=0)

29. (单选题)【选择题】有以下程序:

#include <stdio.h>

main()

{

int i=0,sum=1;

do { sum += i++; }while(i<6);

printf("%d\n",sum);

}

程序的输出结果是( )

  • A. 22
  • B. 18
  • C. 20
  • D. 16

30. (单选题)【选择题】

有以下程序

#include<stdio.h>

main()

{

int y=10;

while(y--);

printf("y=%d\n",y);

}

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

  • A. y=0
  • B. y=-1
  • C. y=1
  • D. while构成无限循环

🎯答案:

1-5:ACBDC

6-10:BAAAA

11-15:CBAAD

16-20:ABCCC

21-25:AAAAD

16-30:AACDB
🎆有问题的小伙伴可以在评论区询问,看到后会回复的,或者关注一下博主,私信询问,100%回复。

相关推荐
music&movie31 分钟前
算法工程师认知水平要求总结
人工智能·算法
秦少游在淮海36 分钟前
C++ - string 的使用 #auto #范围for #访问及遍历操作 #容量操作 #修改操作 #其他操作 #非成员函数
开发语言·c++·stl·string·范围for·auto·string 的使用
const54444 分钟前
cpp自学 day2(—>运算符)
开发语言·c++
虾球xz1 小时前
CppCon 2015 学习:CLANG/C2 for Windows
开发语言·c++·windows·学习
laocui11 小时前
Σ∆ 数字滤波
人工智能·算法
CodeWithMe2 小时前
【C/C++】namespace + macro混用场景
c语言·开发语言·c++
yzx9910132 小时前
Linux 系统中的算法技巧与性能优化
linux·算法·性能优化
全栈凯哥2 小时前
Java详解LeetCode 热题 100(26):LeetCode 142. 环形链表 II(Linked List Cycle II)详解
java·算法·leetcode·链表
全栈凯哥2 小时前
Java详解LeetCode 热题 100(27):LeetCode 21. 合并两个有序链表(Merge Two Sorted Lists)详解
java·算法·leetcode·链表
SuperCandyXu2 小时前
leetcode2368. 受限条件下可到达节点的数目-medium
数据结构·c++·算法·leetcode