当前位置:网站首页>【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个字节
边栏推荐
- EM and REM
- 卸载手机自带APP的操作步骤
- WebAPI整理
- [the most complete and detailed] ten thousand words explanation: activiti workflow engine
- Etcd database source code analysis - cluster membership changes log
- Sequential action localization | fine grained temporal contrast learning for weak supervised temporal action localization (CVPR 2022)
- 对接微信支付(二)统一下单API
- Leetcode:741. picking cherries
- [Oracle SQL] calculate year-on-year and month on month (column to row offset)
- Flex layout
猜你喜欢

Convolutional neural network (II) - deep convolutional network: case study

Leetcode:741. picking cherries

Introduction to three feasible schemes of grammatical generalization

Is the transaction in mysql45 isolated or not?

Full binary tree / true binary tree / complete binary tree~
![[MySQL from introduction to proficiency] [advanced chapter] (VI) storage engine of MySQL tables, comparison between InnoDB and MyISAM](/img/19/ca3a5710ead3c5b9a222a8ae4ecb37.png)
[MySQL from introduction to proficiency] [advanced chapter] (VI) storage engine of MySQL tables, comparison between InnoDB and MyISAM

1.12 Web开发基础

Mysql45 talking about global lock, table lock and row lock

Excitation method and excitation voltage of hand-held vibrating wire vh501tc acquisition instrument

知识沉淀一:架构师是做什么?解决了什么问题
随机推荐
Convolutional neural network (III) - target detection
K. Link with Bracket Sequence I dp
Etcd database source code analysis - cluster membership changes log
数据库sql语言实战
Leetcode:741. picking cherries
Kingbasees SQL language reference manual of Jincang database (7. Conditional expression)
[2023 Jerry technology approval test questions in advance] ~ questions and reference answers
em和rem
VRRP protocol and experimental configuration
[the most complete and detailed] ten thousand words explanation: activiti workflow engine
【Day_06 0423】不要二
Introduction to three feasible schemes of grammatical generalization
金仓数据库 KingbaseES SQL 语言参考手册 (7. 条件表达式)
Xiao He shows his sharp corners and says hello to flutter app
【Day_07 0425】合法括号序列判断
Unity2D 动画器无法 创建过渡
Leetcode:940. How many subsequences have different literal values
How can programmers improve mental internal friction?
"Recursive processing of subproblems" -- judging whether two trees are the same tree -- and the subtree of another tree
金仓数据库 KingbaseES SQL 语言参考手册 (6. 表达式)