当前位置:网站首页>【Day03_0420】C语言选择题
【Day03_0420】C语言选择题
2022-07-26 06:08:00 【安河桥畔】
【Day03_0420】C语言选择题
1.以下程序的输出结果是?(B)
#include <stdio.h>
int main()
{
char a[10] = {
'1','2','3','4','5','6','7','8','9',0 }, * p;
int i;
i = 8;
p = a + i;
printf("%s\n", p - 3);
}
A 6
B 6789
C ‘6’
D 789
ASCII值为0表示为NULL,%s打印遇到ASCII值为0会停止打印
2.以下程序的输出结果是:(D)
#include <iostream>
using namespace std;
void main()
{
int x = 3, y = 3;
switch (x % 2)
{
case 1:
switch (y)
{
case 0:
cout << "first";
case 1:
cout << "second";
break;
default: cout << "hello";
}
case 2:cout << "third";
}
}
A second third
B hello
C first second
D hellothird
3.以下能对二维数组a进行正确初始化的语句是(B)
A int ta[2][]={ {0,1,2},{3,4,5}};
B int ta[][3]={ {0,1,2},{3,4,5}};
C int ta[2][4]={ {0,1,2},{3,4},{5}};
D int ta[][3]={ {0,2},{},{3,4,5}};
解析:
初始化每一行的时候必须连续初始化,中间不能有间隔
4.能把函数处理结果的二个数据返回给主调函数,在下面的方法中不正确的是(A)
A return这二个数
B 形参用数组
C 形参用二个指针
D 用二个全局变量
5.int *p[4] 与选择项中的 说明 (C) 等价
A int p[4]
B int *p
C int *(p[4])
D int (*p)[4]
6.设变量已正确定义,以下不能统计出一行中输入字符个数(不包含回车符)的程序段是(D)
A n=0;while(ch=getchar()!=‘\n’)n++;
B n=0;while(getchar()!=‘\n’)n++;
C for(n=0;getchar()!=‘\n’;n++);
D n=0;for(ch=getchar();ch!=‘\n’;n++);
解析:
for循环的条件初始化部分只执行一次,所以D选项getchar()只能获取一次字符
7.以下代码执行之后ptr指向的内容是?(B)
char* ptr;
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;
A Compiler error
B f
C efg
D defg
8.下面3段程序代码的效果一样吗?(C)
int b;
(1)const int *a = &b;
(2)int const *a = &b;
(3)int *const a = &b;
A (2)=(3)
B (1)=(3)
C (1)=(2)
D 都不一样
E 都一样
解析:
const在*左边修饰*,表示指针指向的内容不可修改
const在*右边修饰指针变量本身,表示其指向不可修改
9.32位系统中,定义**a[3][4],则变量占用内存空间为(B)
A 4
B 48
C 192
D 12
解析:
该变量是一个数组,数组的元素是二级指针
10.假设在一个 32 位 little endian 的机器上运行下面的程序,结果是多少?(B)
#include <stdio.h>
int main(){
long long a = 1, b = 2, c = 3;
printf("%d %d %d\n", a, b, c);
return 0;
}
A 1,2,3
B 1,0,2
C 1,3,2
D 3,2,1
小端:低位存低地址
大端:低位存高地址
long long类型占8个字节,%d打印每次只会读取4个字节
边栏推荐
- Sequential search, half search, block search~
- [Oracle SQL] calculate year-on-year and month on month (column to row offset)
- Interview questions for software testing is a collection of interview questions for senior test engineers, which is exclusive to the whole network
- 金仓数据库 KingbaseES SQL 语言参考手册 (11. SQL语句:ABORT 到 ALTER INDEX)
- Detailed explanation of the whole process of coding's pressure measurement operation
- The time complexity of two recursive entries in a recursive function
- 基于消防GIS系统的智慧消防应用
- 【Oracle SQL】计算同比与环比(列转行进行偏移)
- Amd zen4 game God u reached 208mb cache within this year, which is unprecedented
- CV (1)- Introduction
猜你喜欢

Interview difficulties: difficulties in implementing distributed session, this is enough!

二叉树的前中后序遍历——本质(每个节点都是“根”节点)

金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(十一))

Age is a hard threshold! 42 years old, Tencent level 13, master of 985, looking for a job for three months, no company actually accepted!

Easycvr video square channel display and video access full screen display style problem repair

Kingbasees SQL language reference manual of Jincang database (7. Conditional expression)

Embedded sharing collection 14

Workflow activiti5.13 learning notes (I)

时序动作定位 | 用于弱监督时态动作定位的细粒度时态对比学习(CVPR 2022)

【Oracle SQL】计算同比与环比(列转行进行偏移)
随机推荐
Day110. Shangyitong: gateway integration, hospital scheduling management: Department list, statistics based on date, scheduling details
英语句式参考纯享版 - 定语从句
Kingbasees SQL language reference manual of Jincang database (11. SQL statement: abort to alter index)
1.12 basis of Web Development
“子问题的递归处理”——判断两棵树是不是相同的树——以及 另一颗树的子树
Embedded sharing collection 14
Understanding the mathematical essence of machine learning
Unity2d animator cannot create transition
Calling mode and execution sequence of JS
数据库sql语言实战
Learn about spark project on nebulagraph
Solution to slow download speed of vagrant
Introduction to three feasible schemes of grammatical generalization
Docking wechat payment (II) unified order API
ETCD数据库源码分析——Cluster membership changes日志
K. Link with Bracket Sequence I dp
Code Runner for VS Code,下载量突破 4000 万!支持超过50种语言
[free and easy to use] holiday query interface
C language explanation series - comprehensive exercises, guessing numbers games
Solve vagrant's error b:48:in `join ': incompatible character encodings: GBK and UTF-8 (encoding:: Compatib