考查嵌入式C开发人员的最好的10道题
嵌入式开发人员面试题目

1 / 2姓名:__________ 电话:_________________ 期望薪水:_______ 一,C 语言基础语言基础1,用变量a 给出下面的定义给出下面的定义a) 一个整型数(An integer )b)一个指向整型数的指针(一个指向整型数的指针( A pointer to an integer )c)一个指向指针的的指针,它指向的指针是指向一个整型数( A pointer to a pointer to an integer )d)一个有10个整型数的数组(个整型数的数组( An array of 10 integers )e) 一个有10个指针的数组,该指针是指向一个整型数的。
(An array of 10 pointers to integers ) f) 一个指向有10个整型数数组的指针(个整型数数组的指针( A pointer to an array of 10 integers )g) 一个指向函数的指针,该函数有一个整型参数并返回一个整型数(A pointer to a function thattakes an integer as an argument and returns an integer )h) 一个有10个指针的数组,个指针的数组,该指针指向一个函数,该函数有一个整型参数并返回一个整型数(该指针指向一个函数,该函数有一个整型参数并返回一个整型数( An array of ten pointers to functions that take an integer argument and return an integer )2,关键字static 的作用是什么?的作用是什么?3,关键字const 有什么含意?有什么含意?4,关键字volatile 有什么含意?5,中断是嵌入式系统中重要的组成部分,这导致了很多编译开发商提供一种扩展—让标准C 支持中断。
嵌入式开发考题

嵌入式开发考题
嵌入式开发考题通常涉及嵌入式系统的基本概念、硬件知识、编程技能以及实际应用问题。
以下是一些常见的嵌入式开发考题类型:
1. 基本概念题:这类题目会考查嵌入式系统的定义、特点、组成以及与普通计算机系统的区别等基础知识。
2. 硬件知识题:嵌入式开发离不开对硬件的深刻理解,因此考题中会包含微控制器(MCU)的选择、接口技术(如I2C、SPI、UART等)、处理器架构、存储器类型和容量等方面的问题。
3. 编程与调试题:这类题目侧重于考查候选人在嵌入式环境下的编程能力,包括C语言编程、汇编语言、数据结构、算法优化、调试工具使用等。
4. 操作系统题:针对使用嵌入式操作系统(如RTOS)的场景,考题可能会涉及任务管理、资源分配、同步与通信、中断处理等内容。
5. 实际应用题:这类题目通常要求候选人根据给定的应用场景,设计相应的嵌入式系统方案,包括硬件选型、软件架构设计、性能评估等。
6. 综合题:考查候选人在嵌入式领域的综合素质,可能会涉及项目管理、团队合作、产品生命周期管理等方面的问题。
备考嵌入式开发考题时,建议从以下几个方面入手:
- 理论基础:深入理解嵌入式系统的工作原理和设计方法。
- 实践经验:通过实际项目或实验室操作,增强对嵌入式开发流程的认识。
- 编程技能:熟练掌握C/C++等嵌入式编程语言,具备良好的编程习惯。
- 调试能力:学会使用JTAG、逻辑分析仪等调试工具,提高问题诊断和解决能力。
- 学习资源:利用网络资源、专业书籍、培训课程等途径,不断扩展知识面。
通过全面的准备和持续的学习,可以有效提高在嵌入式开发考题上的表现。
嵌入式linux c开发常见笔试题目

嵌入式Linux C开发的常见笔试题目主要围绕C语言基础、Linux操作系统以及嵌入式系统开发等方面。
以下是一些可能的笔试题目:
1. 请解释C和C++的主要区别。
2. 描述一下静态变量和全局变量在内存中的分配情况。
3. 解释一下什么是预处理器以及它的主要作用。
4. 编写一个程序,实现两个整数的交换而不使用第三个变量。
5. 描述一下进程和线程的区别以及它们之间的关系。
6. 什么是死锁?请列举至少两种导致死锁的情况。
7. 请解释一下中断处理程序的工作原理。
8. 如何在Linux中创建一个新进程?
9. 描述一下Linux中的同步和异步机制。
10. 什么是RTOS?请列举至少两个RTOS的例子。
嵌入式考试题库及答案

嵌入式考试题库及答案一、单项选择题(每题2分,共20分)1. 在嵌入式系统中,通常采用哪种类型的处理器?A. 通用处理器B. 精简指令集处理器(RISC)C. 复杂指令集处理器(CISC)D. 专用处理器答案:B2. 以下哪个不是嵌入式系统的典型特点?A. 实时性B. 可扩展性C. 资源受限D. 专用性答案:B3. 在嵌入式系统中,以下哪个不是常用的存储介质?A. ROMB. RAMC. 硬盘D. Flash答案:C4. 嵌入式操作系统与通用操作系统的主要区别是什么?A. 嵌入式操作系统更复杂B. 嵌入式操作系统更简单,资源占用少C. 嵌入式操作系统价格更高D. 嵌入式操作系统运行速度更快答案:B5. 以下哪个不是嵌入式系统的应用领域?A. 消费电子B. 工业控制C. 航空航天D. 办公自动化答案:D6. 在嵌入式系统中,通常使用哪种类型的编程语言?A. 汇编语言B. 高级语言C. 机器语言D. 以上都是答案:D7. 以下哪个不是嵌入式系统的开发工具?A. 编译器B. 调试器C. 项目管理软件D. 文字处理软件答案:D8. 在嵌入式系统中,以下哪个不是常用的通信协议?A. TCP/IPB. USARTC. I2CD. USB答案:D9. 嵌入式系统的功耗通常与什么因素有关?A. 处理器速度B. 存储容量C. 系统复杂度D. 以上都是答案:D10. 以下哪个不是嵌入式系统的开发流程?A. 需求分析B. 系统设计C. 编码实现D. 产品发布答案:D二、多项选择题(每题3分,共15分)1. 嵌入式系统的开发过程中,以下哪些是必须考虑的因素?A. 系统性能B. 成本控制C. 系统安全性D. 用户体验答案:ABCD2. 在嵌入式系统中,以下哪些是常见的输入设备?A. 触摸屏B. 键盘C. 鼠标D. 传感器答案:ABD3. 以下哪些是嵌入式系统开发中常用的软件工具?A. 集成开发环境(IDE)B. 版本控制系统C. 项目管理工具D. 数据库管理系统答案:ABC4. 在嵌入式系统中,以下哪些是常见的输出设备?A. 显示器B. 扬声器C. 打印机D. LED灯答案:ABD5. 嵌入式系统的测试通常包括哪些方面?A. 功能测试B. 性能测试C. 安全性测试D. 稳定性测试答案:ABCD三、填空题(每题2分,共20分)1. 嵌入式系统通常由、、和四个部分组成。
单片机嵌入式应聘测试题(含答案)

嵌入式工程师预备考试题学校___ ____________ 教师___ ________________ ____________ ___ ______________本次测试包括C编程(70分)、MCU基础(20分)、逻辑题(10分)C编程部分:一、选择题(本大题有10个小题,每个小题3分,共30分)1.以下定义变量方法错误之一是( C )A) int ab_2 B) int _2a3 C) int 2_ab D) int ab2_2.判断char变量ch是否为大写字母的正确表达式为(B )A)'A'<=ch<='Z' B) (ch>='A') && (ch<='Z')C) (ch>='A')& (ch<='Z') D) ('A'<=ch) AND ('Z'>=ch)3.有一个描述:char w;int x;double y;表达式w*xy值的数据类型是( D )A) 浮点B) 字符C) 整数D) 双精度4.下列说法正确的是(D )在C 语言中A)实参及其对应的形参各占一个独立的存储单元B)实参及其对应的形参占用一个存储单元C)只有当实参与其对应的形参同名时,才一起占用存储单元D)形式参数是虚拟的,不占用存储单元5.运行以下程序的结果是(C )#include <stdio.h>int a[3][3]={{1},{2},{3}};诠释b[3][3]={1,2,3,4,5};主函数(){printf("%d\n",a[1][0] + b[1][0]);返回0;}A) 2 B) 4 C) 6 D)值不一定6.运行以下程序的结果是(D )#include “stdio.h”主函数(){int x=1, y=0, a=0, b=0;开关(x){情况1:开关(y){案例0:a++;案例1:b++;}案例2:a++;b++;}printf("a=%d, b=%d\n", a, b) ;}A)a= 1,b=0 B) a=1,b=1 C)a=2,b=1 D) a=2,b=27.有以下程序段int a[10]={1,2,3,4,5,6,7,8,9,10}, *p=&a[3] , b;b=p[5];b 中的值为( D)A)5 B)6 C)8 D)98.运行以下程序的结果是(C )#include <stdio.h>结构研究{整数;字符名称[1 0];年龄;};无效乐趣(结构stu *p){printf("%s\n",(*p).name);}诠释主要(){结构学生[3]={{100,"赵",20},{101,"钱",19},{102,"太阳",18} };有趣(学生+2);}A) 赵B) 钱C) 孙D) 1019.完成C源文件的编辑后,到可执行文件的生成,C语言处理系统必须执行的步骤是(D )A) 编辑、编译、组装、链接B) 组装、编译、运行C) 预编译、编译、汇编、D) 编辑、编译、链接、运行10.函数调用语句:fseek(fp,-20L,SEEK_END);意思是(一)一)将文件位置指针从文件头移动到20 个字节乙)将文件位置指针从当前位置向后移动20 个字节三)将文件位置指针从文件末尾移回20 个字节D ) 将文件位置指针从当前位置移动20 个字节二、空题(共4小题,每小题3分,共12分)1.初始化值为155 的无符号短整型变量a 以____ unsigned short int a=155 _______的形式定义。
嵌入式开发 试题

嵌入式开发试题
1. 嵌入式系统的定义是什么?
2. 请列举几种常见的嵌入式操作系统。
3. 什么是实时操作系统(RTOS)?它在嵌入式系统中的作用是什么?
4. 请解释中断和异常的区别。
5. 什么是嵌入式系统的硬件平台?请列举几种常见的嵌入式硬件平台。
6. 请解释嵌入式系统的软件架构,并举例说明。
7. 什么是嵌入式系统的开发流程?请简要描述每个阶段的主要任务。
8. 请解释嵌入式系统的功耗优化方法。
9. 什么是嵌入式系统的调试方法?请列举几种常见的调试工具。
10. 请解释嵌入式系统的内存管理策略。
11. 什么是嵌入式系统的通信协议?请列举几种常见的通信协议。
12. 请解释嵌入式系统的安全机制,并举例说明。
13. 什么是嵌入式系统的故障诊断方法?请列举几种常见的故障
诊断工具。
14. 请解释嵌入式系统的测试方法,并举例说明。
15. 什么是嵌入式系统的可靠性评估方法?请列举几种常见的可
靠性评估指标。
考查嵌入式C开发人员的最好的16道题

考查嵌入式C开发人员的最好的16道题约定:1) 下面的测试题中,认为所有必须的头文件都已经正确的包含了2)数据类型char 一个字节 1 byteint 两个字节 2 byte (16位系统,认为整型是2个字节)long int 四个字节 4 bytefloat 四个字节4 byetdouble 八个字节 8 bytelong double 十个字节 10 bytepointer 两个字节 2 byte(注意,16位系统,地址总线只有16位)第1题: 考查对volatile关键字的认识#include<setjmp.h>static jmp_buf buf;main(){volatile int b;b =3;if(setjmp(buf)!=0){printf("%d ", b);exit(0);}b=5;longjmp(buf , 1);}请问,这段程序的输出是(a) 3(b) 5(c) 0(d) 以上均不是第1题: (b)volatile字面意思是易于挥发的。
这个关键字来描述一个变量时,意味着给该变量赋值(写入)之后,马上再读取,写入的值与读取的值可能不一样,所以说它"容易挥发"的。
这是因为这个变量可能一个寄存器,直接与外部设备相连,你写入之后,该寄存器也有可能被外部设备的写操作所改变;或者,该变量被一个中断程序,或另一个进程改变了.volatile variable isn't affected by the optimization. Its value after the longjump is the last value variable assumed.b last value is 5 hence 5 is printed.setjmp : Sets up for nonlocal goto /* setjmp.h*/Stores context information such as register values so that the lomgjmp function can return control to the statement following the one calling setjmp.Returns 0 when it is initially called.Lonjjmp: longjmp Performs nonlocal goto /* setjmp.h*/Transfers control to the statement where the call to setjmp (which initialized buf) was made. Execution continues at this point as if longjmp cannot return the value 0.A nonvolatile automatic variable might be changed by a call tolongjmp.When you use setjmp and longjmp, the only automatic variables guaranteed to remain valid are those declared volatile.Note: Test program without volatile qualifier (result may very)第2题:考查类型转换main(){struct node{int a;int b;int c;};struct node s= { 3, 5,6 };struct node *pt = &s;printf("%d" , *(int*)pt);}这段程序的输出是:(a) 3(b) 5(c) 6(d) 7第2题: (a)The members of structures have address in increasing order of their declaration. If a pointer to a structure is cast to the type of a pointer to its first member, the result refers to the first member.第3题:考查递归调用int foo ( int x , int n){int val;val =1;if (n>0){if (n%2 == 1) val = val *x;val = val * foo(x*x , n/2);}return val;}这段代码对x和n完成什么样的功能(操作)?(a) xn(b) x*n(c) nx(d) 以上均不是第3题: (a)Non recursive version of the programint what ( int x , int n){int val;int product;product =1;val =x;while(n>0){if (n%2 == 1)product = product*val;n = n/2;val = val* val;}}/* Code raise a number (x) to a large power (n) using binary doubling strategy */Algorithm description(while n>0){if next most significant binary digit of n( power) is onethen multiply accumulated product by current val ,reduce n(power) sequence by a factor of two using integer division .get next val by multiply current value of itself}第4题:考查指针main(){int a[5] = {1,2,3,4,5};int *ptr = (int*)(&a+1);printf("%d %d" , *(a+1), *(ptr-1) );}这段程序的输出是:(a) 2 2(b) 2 1(c) 2 5(d) 以上均不是第4题: (c)type of a is array of inttype of &a is pointer to array of intTaking a pointer to the element one beyond the end of an array is sure to work. 第5题:考查多维数组与指针void foo(int [][3] );main()int a [3][3]= { { 1,2,3} , { 4,5,6},{7,8,9}}; foo(a);printf("%d" , a[2][1]);}void foo( int b[][3]){++ b;b[1][1] =9;}这段程序的输出是:(a) 8(b) 9(c) 7(d)以上均不对第5题: (b)第6题目:考查逗号表达式main(){int a, b,c, d;a=3;b=5;c=a,b;d=(a,b);printf("c=%d" ,c);printf("d=%d" ,d);}这段程序的输出是:(a) c=3 d=3(b) c=5 d=3(c) c=3 d=5(d) c=5 d=5第6题: (c)The comma separates the elements of a function argument list. The comma is also used as an operator in comma expressions. Mixing the two uses of comma is legal, but you must use parentheses to distinguish them. the left operand E1 is evaluated as a void expression, then E2 is evaluated to give the result and type of the comma expression. By recursion, the expressionE1, E2, ..., Enresults in the left-to-right evaluation of each Ei, with the value and type of En giving the result of the whole expression.c=a,b; / *yields c=a* /d=(a,b); /* d =b */第7题:考查指针数组main(){int a[][3] = { 1,2,3 ,4,5,6};int (*ptr)[3] =a;printf("%d %d " ,(*ptr)[1], (*ptr)[2] );++ptr;printf("%d %d" ,(*ptr)[1], (*ptr)[2] );}这段程序的输出是:(a) 2 3 5 6(b) 2 3 4 5(c) 4 5 0 0(d) 以上均不对第7题: (a)/* ptr is pointer to array of 3 int */第8题:考查函数指针int *f1(void){int x =10;return(&x);}int *f2(void){int*ptr;*ptr =10;return ptr;}int *f3(void){int *ptr;ptr=(int*) malloc(sizeof(int));return ptr;}上面这3个函数哪一个最可能引起指针方面的问题(a) 只有 f3(b) 只有f1 and f3(c) 只有f1 and f2(d) f1 , f2 ,f3第8题: (c)f1 and f2 return address of local variable ,when function exit local variable disappeared第9题:考查自加操作(++)main(){int i=3;int j;j = sizeof(++i+ ++i);printf("i=%d j=%d", i ,j);}这段程序的输出是:(a) i=4 j=2(b) i=3 j=2(c) i=3 j=4(d) i=3 j=6第9题: (b)sizeof operator gives the number of bytes required to store an object of the type of its operand . The operands is either an expression, which is not evaluated( (++i + ++ i ) is not evaluated so i remain 3 and j is sizeof int that is 2) or a parenthesized type name.第10题:考查形式参数,实际参数,指针和数组void f1(int *, int);void f2(int *, int);void(*p[2]) ( int *, int);main(){int a;int b;p[0] = f1;p[1] = f2;a=3;b=5;p[0](&a , b);printf("%d\t %d\t" , a ,b);p[1](&a , b);printf("%d\t %d\t" , a ,b);}void f1( int* p , int q){int tmp;tmp =*p;*p = q;q= tmp;}void f2( int* p , int q){int tmp;tmp =*p;*p = q;q= tmp;}这段程序的输出是:(a) 5 5 5 5(b) 3 5 3 5(c) 5 3 5 3(d) 3 3 3 3第10题: (a)void(*p[2]) ( int *, int);define array of pointer to function accept two argument that is pointer to int and return int. p[0] = f1; p[1] = f2 contain address of function .function name without parenthesis represent address of function Value and address of variable is passed to function only argument that is effected is a (address is passed). Because of call by value f1, f2 can not effect b第11题:考查自减操作(--)void e(int );main(){int a;a=3;e(a);}void e(int n){if(n>0){e(--n);printf("%d" , n);e(--n);}}这段程序的输出是:(a) 0 1 2 0(b) 0 1 2 1(c) 1 2 0 1(d) 0 2 1 1第11题: (a)第12题:考查typedef类型定义,函数指针typedef int (*test) ( float * , float*)test tmp;tmp 的类型是(a) 函数的指针,该函数以两个指向浮点数(float)的指针(pointer)作为参数(arguments)Pointer to function of having two arguments that is pointer to float(b) 整型(c) 函数的指针,该函数以两个指向浮点数(float)的指针(pointer)作为参数(arguments),并且函数的返回值类型是整型Pointer to function having two argument that is pointer to float and return int(d) 以上都不是第12题: (c)C provide a facility called typedef for creating new data type names, for example declarationtypedef char stringMakes the name string a synonym for int .The type string can be used in declaration, cast, etc, exactly the same way that the type int can be. Notice that the type being declared in a typedef appears in the position of a variable name not after the word typedef.第13题:数组与指针的区别与联系main(){char *p;char buf[10] ={ 1,2,3,4,5,6,9,8};p = (buf+1)[5];printf("%d" , p);}这段程序的输出是:(a) 5(b) 6(c) 9(d) 以上都不对第13题: (c)If the type of an expression is "array of T" for some type T, then the value of the expression is a pointer to the first object in the array, and the type of the expression is altered to "pointer to T"So (buf+1)[5] is equvalent to *(buf +6) or buf[6]第14题:Void f(char**);main(){char * argv[] = { "ab" ,"cd" , "ef" ,"gh", "ij" ,"kl" }; f( argv );}void f( char **p ){char* t;t= (p+= sizeof(int))[-1];printf( "%s" , t);}这段程序的输出是:(a) ab(b) cd(c) ef(d) gh第14题: (b)p+=sizeof(int) point to argv[2](p+=sizeof(int))[-1] points to argv[1] 第15题:#include<stdarg.h>int ripple ( int , ...);main(){int num;num = ripple ( 3, 5,7);printf( " %d" , num);}int ripple (int n, ...){int i , j;int k;va_list p;k= 0;j = 1;va_start( p , n);for (; j<n; ++j){i = va_arg( p , int);for (; i; i &=i-1 )++k;}return k;}这段程序的输出是:(a) 7(b) 6(c) 5(d) 3第15题: (c)When we call ripple value of the first argument passed to ripple is collected in the n that is 3. va_start initialize p to point to first unnamed argument that is 5 (first argument).Each call of va_arg return an argument and step p to the next argument. va_arg uses a type name to determine what type to return and how big a step to take Consider inner loop(; i; i&=i-1) k++ /* count number of 1 bit in i *in five number of 1 bits is (101) 2in seven number of 1 bits is (111) 3hence k return 5examplelet i= 9 = 1001i-1 = 1000(i-1) +1 = i1000+11 001The right most 1 bit of i has corresponding 0 bit in i-1 this way i & i-1, in a two complement number system will delete the right most 1 bit I(repeat until I become 0 gives number of 1 bits)第16题:int counter (int i){static int count =0;count = count +i;return (count );}main(){int i , j;for (i=0; i <=5; i++)j = counter(i);}The value of j at the end of the execution of the this program is:(a) 10(b) 15(c) 6(d) 7第16题: (b)The answer is (b)Static variable count remain in existence rather than coming and going each time function is calledso first call counter(0) count =0second call counter(1) count = 0+1;third call counter(2) count = 1+2; /* count = count +i */fourth call counter(3) count = 3+3;fifth call counter(4) count = 6+4;sixth call counter(5) count = 10+5;。
经典嵌入式工程师面试C语言题目

嵌入式C 语言面试题目汇总(一)一、预处理(Preprocessor )1、用预处理指令#define 声明一个常数,用以表明1年中有多少秒(忽略闰年问题)年中有多少秒(忽略闰年问题)2、写一个"标准"宏MIN ,这个宏输入两个参数并返回较小的一个。
,这个宏输入两个参数并返回较小的一个。
二、死循环(Infinite loops )3、嵌入式系统中经常要用到无限循环,你怎么样用C 编写死循环呢?编写死循环呢?三、数据声明(Data declarations )4、用变量a 给出下面的定义给出下面的定义a)、一个整型数(An integer )b)、一个指向整型数的指针(、一个指向整型数的指针( A pointer to an integer) c)、一个指向指针的的指针,它指向的指针是指向一个整型数( A pointer to a pointer to an intege )d)、一个有10个整型数的数组(个整型数的数组( An array of 10 integers) e)、 一个有10个指针的数组,该指针是指向一个整型数的。
(An array of 10 pointers to integers )f)、 一个指向有10个整型数数组的指针(个整型数数组的指针( A pointer to an array of 10 integers) g)、 一个指向函数的指针,该函数有一个整型参数并返回一个整型数(A A pointer pointer pointer to to to a a function that takes an integer as an argument and returns an integer )h)、 一个有10个指针的数组,该指针指向一个函数,该函数有一个整型参数并返回一个整型数(个整型数( An An array array array of of of ten ten ten pointers pointers pointers to to to functions functions functions that that that take take take an an an integer integer integer argument argument argument and and and return return return an an integer )5、关键字static 的作用是什么?的作用是什么?1)在函数体,一个被声明为在函数体,一个被声明为静态静态静态的变量在这一函数被的变量在这一函数被的变量在这一函数被调调用过程过程中中维持其值不维持其值不变。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
(三)考查嵌入式C开发人员的最好的10道题
自测简介:
开发人员,对编程语言必须有扎实的基本功。
本套自测集中考察C++这门主流的程序设计语言的基础知识,涉及C++的语法基础、函数的概念、参数传递等,既有一般的概念理解题,也有实际的代码应用题,可供C++语言入门者检测自己对Java基础的掌握水平。
建议做题的朋友在做代码题时最好不要去直接运行代码得出结果选项,而是根据自己的水平和理解来选择,测出自己的真实水平,做完后再去运行代码进行核对检查,再次做题促进提高。
相关自测:
验证你JAVA掌握程度的自测题(一)
验证你JAVA掌握程度的自测题(二)
C/C++程序员面试不再愁,世界名企面试题帮你忙
第 1 题
考查对volatile关键字的认识
#include<setjmp.h>static jmp_buf buf;main() { volatile int b; b
=3; if(setjmp(buf)!=0) { printf("%d ",
b); exit(0); } b=5; longjmp(buf , 1);} 请问,这段程序的输出是【】
A. 3
B. 5
C. 0
D. 以上均不是
正确答案:B
第 2 题
考查类型转换
main(){ struct node { int a; int b; int c; }; struct node s= { 3, 5,6 }; struct node *pt = &s; printf("%d" , *(int*)pt);} 这段程序的输出是:【】
A. 3
B. 5
C. 6
D. 7
正确答案:A
第 3 题
考查递归调用
int foo ( int x , int n){ int val; val =1; if (n>0) { if (n%2 ==
1) val = val *x; val = val * foo(x*x , n/2); } return val;} 这段代码对x 和n完成什么样的功能(操作)?
A. x^n (x的n次幂)
B. x*n(x与n的乘积)
C. n^x(n的x次幂)
D. 以上均不是
正确答案:A
第 4 题
考查指针,这道题只适合于那些特别细心且对指针和数组有深入理解的人
main() { int a[5] = {1,2,3,4,5}; int *ptr = (int*)(&a+1); printf("%d %d" , *(a+1), *(ptr-1) );} 这段程序的输出是:【】
A. 2 2
B. 2 1
C. 2 5
D. 以上均不是
正确答案:C
第 5 题
考查多维数组与指针
void foo(int [][3] ); main(){ int a [3][3]= { { 1,2,3} ,
{ 4,5,6},{7,8,9}}; foo(a); printf("%d" , a[2][1]);}void foo( int
b[][3]) { ++ b; b[1][1] =9;} 这段程序的输出是:【】
A. 8
B. 9
C. 7
D. 以上均不对
正确答案:B
第 6 题
考查逗号表达式
main(){ int a, b,c,
d; a=3; b=5; c=a,b; d=(a,b); printf("c=%d" ,c); printf("d=%d" ,d);}这段程序的输出是:【】
A. c=3 d=3
B. c=5 d=3
C. c=3 d=5
D. c=5 d=5
正确答案:C
考查指针数组
main(){ int a[][3] = { 1,2,3 ,4,5,6}; int (*ptr)[3] =a; printf("%d %d " ,(*ptr)[1], (*ptr)[2] ); ++ptr; printf("%d %d" ,(*ptr)[1], (*ptr)[2] );}这段程序的输出是:【】
A. 2 3 5 6
B. 2 3 4 5
C. 4 5 0 0
D. 以上均不对
正确答案:A
第8 题
考查函数指针
int *f1(void){ int x =10; return(&x);}int *f2(void){ int*ptr; *ptr
=10; return ptr;}int *f3(void){ int *ptr; ptr=(int*)
malloc(sizeof(int)); return ptr;}上面这3个函数哪一个最可能引起指针方面的问题
A. 只有f3
B. 只有f1 and f3
C. 只有f1 and f2
D. f1 , f2 ,f3
正确答案:C
考查自加操作(++)
main(){ int i=3; int j; j = sizeof(++i+ ++i); printf("i=%d j=%d", i ,j);}这段程序的输出是:
A. i=4 j=2
B. i=3 j=2
C. i=3 j=4
D. i=3 j=6
正确答案:B
第10 题
考查形式参数,实际参数,指针和数组
void f1(int *, int); void f2(int *, int); void(*p[2]) ( int *, int);main(){ int a; int b; p[0] = f1; p[1] = f2; a=3; b=5; p[0](&a , b); printf("%d\t %d\t" ,
a ,b); p[1](&a , b); printf("%d\t %d\t" , a ,b);}void f1( int* p , int q){ int tmp; tmp =*p; *p = q; q= tmp;}void f2( int* p , int q){ int tmp; tmp
=*p; *p = q; q= tmp;} 这段程序的输出是:【】
A. 5 5 5 5
B. 3 5 3 5
C. 5 3 5 3
D. 3 3 3 3
正确答案:A。