当前位置:网站首页>【Day05_0422】C语言选择题
【Day05_0422】C语言选择题
2022-07-26 06:08:00 【安河桥畔】
【Day05_0422】C语言选择题
1.以下程序的输出结果是?(D)
int x = 1;
do {
printf("%2d\n", x++);
} while (x--);
A 1
B 无任何输出
C 2
D 陷入死循环
2.定义char dog[]=“wang\0miao”;那么sizeof(dog)与strlen(dog)分别是多少:(A)
A 10,4
B 4,4
C 9,9
D 9,4
解析:
\0占一个字节空间,\表示转义字符
编译器会给字符串末尾加一个\0
strlen函数遇到\0后就停止统计
3.下列程序的打印结果是?(D)
char p1[15] = "abcd", * p2 = "ABCD", str[50] = "xyz";
strcpy(str + 2, strcat(p1 + 2, p2 + 1));
printf("%s", str);
A xyabcAB
B abcABz
C ABabcz
D xycdBCD
E 运行出错
解析:
4.下面程序的输出结果是(B)
#include<iostream.h>
void main() {
int n[][3] = {
10,20,30,40,50,60 };
int(*p)[3];
p = n;
cout << p[0][0] << "," << *(p[0] + 1) << "," << (*p)[2] << endl;
}
A 10,30,50
B 10,20,30
C 20,40,60
D 10,30,60
解析:
p表示一个指向有三个整型元素的数组的指针
p[0]等价于*(p+0),表示数组的第0行,即第0个一维数组的数组名,也即第0个一维数组首元素的地址
5.以下说法中正确的是(B)。
A C++程序中的main()函数必须放在程序的开始部分
B C++程序的入口函数是main函数
C 在C++程序中,要调用的函数必须在main()函数中
6.以下程序运行结果为:(D)
#include<iostream>
using namespace std;
char fun(char x, char y) {
if (x < y)
return x;
return y;
}
int main() {
int a = '1', b = '1', c = '2';
cout << fun(fun(a, b), fun(b, c));
return 0;
}
A 运行出错
B 2
C 3
D 1
7.对于int* pa[5];的描述,以下哪个选项是正确的(A)
A pa是一个具有5个元素的指针数组,每个元素是一个int类型的指针;
B pa是一个指向数组的指针,所指向的数组是5个int类型的元素;
C pa[5]表示某个数的第5个元素的值;
D pa是一个指向某个数组中第5个元素的指针,该元素是int类型的变量
8.下面两个结构体,在#pragma pack(4)和#pragma pack(8)的情况下,结构体的大小分别是(C)
struct One {
double d;
char c;
int i;
}
struct Two {
char c;
double d;
int i;
}
A 16 24,16 24
B 16 20,16 20
C 16 16,16 24
D 16 16,24 24
9.下面哪个指针表达式可以用来引用数组元素a[i] [j] [k] [l]()
A (((a+i)+j)+k)+l)
B *(*(*(*(a+i)+j)+k)+l)
C (((a+i)+j)+k+l)
D ((a+i)+j+k+l)
他的回答: (错误)
正确答案: B
解析:
10.由多个源文件组成的C程序,经过编辑、预处理、编译、链接等阶段会生成最终的可执行程序。下面哪个阶段可以发现被调用的函数未定义?(C)
A 预处理
B 编译
C 链接
D 执行
解析:
预处理:头文件展开,宏替换,处理预编译指令,去注释等
编译:检查语法错误,生成汇编代码
汇编:将编译完成的汇编指令翻译成对应的二进制文件
链接:将多个目标文件拼接成一个,解决地址问题
边栏推荐
- H. Take the Elevator 贪心
- Latex merges multiple rows and columns of a table at the same time
- Latex同时合并表格的多行多列
- Code Runner for VS Code,下载量突破 4000 万!支持超过50种语言
- Kingbasees SQL language reference manual of Jincang database (11. SQL statement: abort to alter index)
- 对接微信支付(二)统一下单API
- Cdga | how to build data asset catalogue?
- Jincang database kingbasees SQL language reference manual (5. Operators)
- Leetcode:336. palindrome pair
- Solve vagrant's error b:48:in `join ': incompatible character encodings: GBK and UTF-8 (encoding:: Compatib
猜你喜欢

Intelligent fire protection application based on fire GIS system

Registration conditions for system integration project management engineer (intermediate level of soft exam) in the second half of 2022

Introduction of four redis cluster schemes + comparison of advantages and disadvantages

1.12 Web开发基础

Youwei low code: Brick life cycle component life cycle

Mysql45 talking about global lock, table lock and row lock

Introduction to three feasible schemes of grammatical generalization

Meiker Studio - Huawei 14 day Hongmeng equipment development practical notes 4

【(SV && UVM) 笔试面试遇到的知识点】~ phase机制

Leetcode:336. palindrome pair
随机推荐
实习运维知识积累
移动web
Interview difficulties: difficulties in implementing distributed session, this is enough!
Convolutional neural network (II) - deep convolutional network: case study
Excitation method and excitation voltage of hand-held vibrating wire vh501tc acquisition instrument
Modifiers should be declared in the correct order
Understanding the mathematical essence of machine learning
C language explanation series - comprehensive exercises, guessing numbers games
Flex layout
平衡二叉树(AVL) ~
Concurrency opening -- take you from 0 to 1 to build the cornerstone of concurrency knowledge system
某公司给每个工位装监控:只为看员工写代码?
Is the transaction in mysql45 isolated or not?
程序员如何改善精神内耗?
Kingbasees SQL language reference manual of Jincang database (7. Conditional expression)
Full binary tree / true binary tree / complete binary tree~
Mysql45 talking about infrastructure: how is an SQL query executed?
Solution to slow download speed of vagrant
Acquisition of bidding information
“子问题的递归处理”——判断两棵树是不是相同的树——以及 另一颗树的子树
