当前位置:网站首页>c语言学习回顾---1 基础知识回顾
c语言学习回顾---1 基础知识回顾
2022-06-10 17:31:00 【要努力丫!】
1、下面哪个不是C语言的内置的数据类型?
A、 char
B、double
C、struct Stu
D、short
2、局部变量的作用域是________A、main函数内部
B、整个程序
C、main函数之前
D、局部变量所在的局部范围
3、下面代码的输出结果是______
#include <stdio.h>
int num = 10;
int main()
{
int num = 1;
printf("%d\n",num);
return 0;
}
A、程序有问题,不能编译
B、输出1
C、输出10
D、输出0
4、字符串结束的标志是_______A、 ‘0’
B、EOF
C、‘\0’
D、空格
5、下面代码的结果是______
#include <stdio.h>
#include <string.h>
int main()
{
char arr[] = {
'c','a','t'};
printf("%d\n",strlen(arr));
return 0;
}
A、3
B、4
C、随机值
D、5
6、下面哪个不是转义字符?A、‘\n’
B、‘\060’
C、‘\q’
D、‘\b’
7、关于数组描述错误的是_____A、数组是一组相同类型元素的结合
B、数组的下标是从1开始的
C、数组的下标是从0开始的
D、数组如果初始化,可以不指定数组大小
8、C语言中哪个数组的创建是错误的?A、
int char[10]={0}B、
int n =10; int arr[n] = {0}C、
int arr[] ={1,2,3,4,5,6,7,8,9,0}D、
char ch[10]="hello"
9、下面代码的结果是?
#include <stdio.h>
#include <string.h>
int main()
{
printf("%d\n",strlen("c:\test\121"));
return 0;
}
- A、7
- B、8
- C、9
- D、10
10、编程:求两个数的较大值,写一个函数来求两个整数的较大值,如:输入10,20;输出较大值20.
int Max(int x, int y)
{
int m = x > y ? x : y;
return m;
/*if (x > y) return x; else return y;*/
}
int main()
{
int a = 0;
int b = 0;
scanf("%d %d", &a, &b);
int max = Max(a , b);
printf("较大值为:%d\n",max);
return 0;
}
运行结果如下:
25 35
较大值为:35
11、关于C语言的关键字说法正确的是____
A、关键字可以自己创建
B、关键字不能自己创建
C、关键字可以作变量名
D、typedef不是关键字
12、下面哪个不是关键字?A、 int
B、struct
C、define
D、continue
13、关于指针的说法正确的是______A、sizeof(char *)的大小一定是1
B、指针是个变量,用来存放地址
C、指针变量的大小都是4个字节
D、指针不是变量
14、关于static说法不正确的是______A、static可以修饰局部变量
B、static可以修饰全局变量
C、static修饰的变量不能改变
D、static可以修饰函数
15、下面代码的结果是什么
int sum(int a)
{
int c = 0;
static int b = 3;
c += 1;
b += 2;
return(a + b + c);
}
int main()
{
int i;
int a = 2;
for (i = 0; i < 5; i++)
{
printf("%d ",sum(a));
}
return 0;
}
A、6,8,10,12,14
B、8,10,12,14,16
C、10,12,14,16,18
D、12,14,16,18,20
16、用在Switch语言中的关键字不包含哪个?A、continue
B、break
C、default
D、case
17、牛客网—小飞机
KiKi学会了printf在屏幕输出信息,他想输出一架小飞机。请帮他编写程序输出这架小飞机。
#include <stdio.h>
int main()
{
int i;
for (i = 0; i < 2; i++)
{
printf(" ** \n");
}
for (i = 0; i < 2; i++)
{
printf("************\n");
}
for (i = 0; i < 2; i++)
{
printf(" * * \n");
}
return 0;
}
运行结果:
**
**
************
************
* *
* *
18、牛客网—被5整除
判断一个整数是否能5整除是一个挺简单的问题,懒惰的KiKi还是不想自己做,于是找到你帮他写代码,你就帮帮他吧。
#include <stdio.h>
int main()
{
printf("请输入一个数字(在0到100000之间):");
int M = 0;
scanf("%d", &M);
if (M % 5 == 0)
printf("YES");
else
printf("NO");
return 0;
}
请输入一个数字(在0到100000之间):20
YES
答案
1、C
2、D
如果在一个程序的开头声明一个变量:
void test()
{
int b = 0;
}
int main()
{
int a = 10;
return 0;
}
其中a与b都是局部变量,可知选项ABC都是错误的
3、B
考察局部变量与全局变量同名字的时候,局部变量优先
4、C
5、C
给其开辟一块空间存放’c’ ‘a’ ‘t’,但是不知道什么时候能遇到字符的结束标志,所以运行结果为随机值。
6、C
7、B
8、B
B选项中,n是变量,在创建数组的时候,指定n的大小,用的是常量。在c99标准中引用一个概念:变长数组,它支持数组创建的时候用变量指定大小,但是这个数组不能初始化。vs2019不支持c99中的变长数组。
9、A
\t以及\121都会被转义
11、B
12、C
define以及include都是预处理指令的符号
13、B
A选项char * 也是指针类型,指针类型的大小不是4个字节就是8个字节
D选项:通常意义上讲的都是指针变量
14、C
15、B
int sum(int a)
{
int c = 0;
static int b = 3;
c += 1;
b += 2;
return(a + b + c);
}
int main()
{
int i;
int a = 2;
for (i = 0; i < 5; i++)
{
printf("%d ",sum(a));
}
return 0;
}
该代码会循环执行5次,每执行一次都会调用sum函数,a最开始是2.将a送到int sum(int a)里面,a=2,c+=1,则c=1;b+=2,则b=5;所以第一次返回值是8。
i++执行之后,i变为1,再次进入循环;这一次,a依然是2,c再次变为0,b还是上次留下来的值,因为b被static修饰了。但是下一次进sum函数的时候,static int b = 3 就没有意义了。此时b已经是5了,5+2=7,所以2+1+7=10,直到i=5时退出循环,每一次循环时只有b在发生改变。
边栏推荐
- 内存池原理一(基于整块)
- 信息学奥赛一本通 1280:【例9.24】滑雪 | OpenJudge NOI 2.6 90:滑雪 | 洛谷 P1434 [SHOI2002] 滑雪
- JS special effect of canvas divergent particle H5 animation
- c语言---14 循环语句for
- Talk about those things about telecommuting, participate in the essay solicitation, receive the contribution fee and win the grand prize!
- 2022版IDEA图形界面GUI乱码解决方法超详细简单版
- 字符串的分析和使用 上
- 关于目前CIM(BIM+GIS)行业的一些看法
- AOV网拓扑排序
- PCA主成分分析教程(origin分析&绘制,无须R语言)
猜你喜欢
随机推荐
正斜杠“/”、反斜杠“\、”转义字符“\”、文件路径分割符傻傻记不清楚
What is image search
Detailed explanation of MySQL windowing function
The latest good article | interpretable confrontation defense based on causal inference
Leetcode String to integer(Atoi)
玩转Pytorch的Function类
IP总结(TCP/IP卷1和卷2)
JS blur shadow follow animation JS special effect plug-in
苹果放大招!这件事干的太漂亮了……
IP summary (tcp/ip volumes 1 and 2)
基于业务沉淀组件 =&gt; manage-table
Unity踩坑记录:如果继承MonoBehaviour,类的构造函数可能会被Unity调用多次,不要在构造函数做初始化工作
Numpy np set_ Usage of printoptions () -- control output mode
js锚点定位可以扩展很多功能
Container containing the most water
js模糊阴影跟随动画js特效插件
CUDA Programming (I): add two arrays
canvas发散的粒子h5动画js特效
2022版IDEA图形界面GUI乱码解决方法超详细简单版
Memory pool principle I (based on the whole block)









