C Language Programming Standard questions

Source: Internet
Author: User
Tags switches

C Language Programming Standard questions

[Description]:

1, this question does not consider the header file reference problem (assuming already contains the correct header file), the C language standard function is available;

2, if not specifically, assume that the program operating environment is: Operating system Windows, the VC6.0 compilation environment, the default is four-byte alignment, X86 (80586) CPU processor (32 bit small byte sequence processor);

3, the test paper needs to be recycled and reused, please answer the answer sheet;

4, this question is divided into 100 points, the answer time is 90 minutes.

I. Single topic (3 points per quiz, total 20 minor 60 points)

() 1.1 program block to be written in indentation style, the number of spaces to indent?

A. 2 B. 4 c. 6 D. 8

() 1.2 The following code correctly conforms to the specification?

A.

Mmi_bool Bsim1valid;

Bsim1valid = srv_sim_ctrl_is_available (Mmi_sim_enum sim);

if (bsim1valid)

{

...//program code

}

Sim_cntx = Srv_sim_ctrl_get_sim_cntx (SIM);

app_strlcpy (Out_imsi_buffer, Sim_cntx->imsi, buffer_size);

B.

rect.length = 0; rect.width = 0;

C.

if (PUSERCR = = NULL) return;

D.

For (...)

{

...//program code

}

if (...)

{

...//program code

}

void Example_fun (void)

{

...//program code

}

() 1.3 add comment when adding new code qicker shortcut command is?

A. ABG b. MBG C. dbg D. MBE

() 1.4 in general, the source program effective annotation amount must be more than the proportion of what?

A. 40% B. 30% c. 20% D. 10%

() 1.5 add function when adding function header comment qicker shortcut command?

A. File B. Func c. fi D. hi

() 1.6 The following domestic software compilation switches are named correctly?

A. __ahong_onekey_saving_mode__

B. __ahong_call_saving_way__

C. __ahong_mmi_normal_ui_176x220__

D. __mmi_ahong_ip_number__

() 1.7 The following code is named in the correct specification?

A. void Set_udt_msg_sls (BYTE SLS);

B. #define _example_0_test_

C. Add_user

D. void Set_sls00 (BYTE SLS);

() 1.8 Compare the following two sections of code:

Typedef struct Example_stru

{

unsigned int valid:1;

person person;

unsigned int set_flg:1;

} EXAMPLE;

typedef struct EXAMPLE_STRU

{

unsigned int valid:1;

unsigned int set_flg:1;

person person;

} EXAMPLE;

How many bytes does the memory space between the left and right sides of the defined structure occupy?

A. 0 B. 1 c. 2 D. 4

() 1.9 which of the following methods is used to protect the global variables of reentrant functions?

A. Open Interrupt B. Signal Volume C. Piping D. Message Queuing

() 1.10 The following description of the function is not correct?

A. a function accomplishes only one function.

B. write functions for simple functions.

C. the size of the function is limited to 300 lines.

D. do not design functions that are multi-purpose and exhaustive.

() 1.11 design function, the function of reasonable fan out should be?

A. less than 7 B. less than 8 C. less than 9 D. less than Ten

() 1.12 The principles described below which are incorrect when optimizing the function structure?

A. the implementation of the module function cannot be affected.

B. carefully examine the module or function error handling and module performance requirements and improve.

C. improve the software structure by decomposing or merging functions.

D. increase the complexity of the interface between functions.

() 1.13 the assertion and other commissioning switches should be turned off in the formal software product.

A. prevent system B from rebooting. Reduce program code space

C. improving the stability of the system D. Speed up software operations

() 1.14 The following about the efficiency of the description is not correct?

A. You should not spend too much time trying to improve the efficiency of a function code that is not frequently called.

B. Minimizing loop nesting levels

C. to pursue a compact code

D. try to use multiplication or other methods instead of division, especially in floating-point operations

() 1.15 has the following program code:

#define OK 0

#define ERR 1

#define ERROR (-1)

#define BUFFER_SIZE 256

Char *getmemory (unsigned long ulsize)

{

char *pcbuf = NULL;

PCBUF = (char *) malloc (ulsize);

if (NULL = = pcbuf)

{

return ERROR;

}

return pcbuf;

}

void Test (void)

{

char *pszbuf = NULL;

Pszbuf = GetMemory (buffer_size);

if (NULL! = pszbuf)

{

strcpy (Pszbuf, "Hello world!\r\n");

printf (PSZBUF);

Free (PSZBUF);

}

Return

}

The following description is correct:

A,pszbuf point to the memory can not exceed 255

B, The exception branch of the GetMemory function returned -1, is an illegal address

C, Abnormal branches in getmemory not free space

D,pcbuf is a local pointer, and the memory pointed to Will be released after GetMemory is called

() 1.16 The following description of the test maintenance is correct?

A. you can solve the problem by "try"

B. clean, tidy or optimized code as long as it is tested

C. maintenance of code versions by means of manual backups

D. code version Upgrade to undergo rigorous testing

() 1.17 The following macro definition is not at risk?

A. #define Rectangle_area (A, B) ((a) * (b))

B. #define Rectangle_area (A, B) (a) * (b)

C. #define RECTANGLE_AREA (A, B) (A * b)

D. #define RECTANGLE_AREA (A, b) A * b

() 1.18 The following code:

#define SQUARE (a) ((a) * (a))

int a = 5;

int b;

b = SQUARE (a++);

What is the value of a and B after execution?

A. A = 6 B = + B. A = 7 B = 25

C. A = 7 B = D. A = 7 B = 36

() 1.19 has the following code:

#define SQUARE (a) ((a) * (a))

int a = 5;

int b;

How do you use macros correctly to conform to the specification?

A.

b = SQUARE (a++);

B.

b = SQUARE (++a);

C.

b = SQUARE (a);

a++;

D.

b = SQUARE ((a) + +);

() 1.20 has the following program code:

#include <stdio.h>

void Main ()

{

Union

{

int k;

Char i[2];

}*s,a;

s = &a;

S->i[0] = 0x19;

S->I[1] = 0x18;

printf ("%x\n", A.K);

}

What is the output?

A. Unpredictable

B. 1819

C. 1918

D. 180019

Two. Fill in the blanks (1 points each, total 20 empty 20 minutes)

2.1 usually in the design of the function, the function is to be low , the function of the interior is high, the function of the call relationship to ____ fan-in, ______ fan out.

2.2 In order to improve the efficiency of the code, it is usually required to cycle the body workload ___, the busiest loop in themulti-cycle in ___.

2.3 Code Quality Assurance Priority principle, the highest priority is to ensure that ___, followed by stability, security,___, Specification / Readability, global efficiency, local efficiency, personal convenience.

2.4 code is mainly to the programming style of the program, such as annotations, naming, and programming error-prone content to be checked by the developers themselves or the way developers, code review is the implementation of the program's functions and procedures for the stability, security, reliability, etc. to check and review, May be done by self-examination, or by other means.

2.5 with the Product Software (project group), it is best to use the same editor and use the same .

2.6 Resource file (multi-language version support), if the resource is language-sensitive, you should leave the resource with the source code file , in the following ways:, or a separate description file (such as database format).

2.7 is best used to confirm the more critical algorithms .

2.8 Local efficiency should be the service, not because of the improvement of local efficiency and impact.

2.9 in the same project group or product group, there is a unified set of integrated test and system to be prepared with the corresponding printing function, and to have detailed instructions.

2.10 checks the validity of all parameter inputs of the function, and also checks the validity of all non-parametric inputs of the function, such as data files, etc.

Three. Programming questions (20 points for each small question, 1 items in 20 points)

3.1 Write the function implementation: the integer number into a string, such as 3489 into "3489". Requires that no C Library functions can be used. The function prototype is declared as follows:

char *inttostring (int num, char *result);

C Language Programming Standard questions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.