C language programming notes C language basics (I), C language programming questions

Source: Internet
Author: User

C language programming notes C language basics (I), C language programming questions
C language is a powerful and concise computer language. It can be used to write programs and instruct computers to complete specified tasks. We can use the C language to create a program (a group of commands) and let the computer act according to the instructions. In addition, C is quite flexible and used to execute almost all the tasks that can be completed by computer programs, including accounting applications, word processing programs, games, and operating systems. It is not only the foundation of more advanced languages (such as C ++), but also the development of mobile phone applications in the form of Objective C. Currently, the latest C language version is defined in ISO/IEC 9899: 2011. Data Structure + algorithm = Program

  • 1.1 C program and Program Design

(1) which of the following statements is false:

A) C program can be compiled and connected to form A truly executable binary machine command file

B) a program written in C language is called a source program. It is stored in a text file in the form of ASCII code.

C) each executable and non-executable statement in C language will eventually be converted into binary machine commands.

D) the C language source program is compiled to generate a target program suffixed with. obj.

Analysis: C does not execute a statement in C language (for example, if the macro definition is replaced with the code after pre-compilation, the command itself does not exist ).

A. the suffix of the source program file is. c B. after C compilation, the source program is suffixed. obj binary file (target file) c. connect the target file with various library functions in C language to generate a suffix. executable files of exe

 

(2) which of the following statements is false:

A) structured programs consist of three basic structures: sequence, branch, and loop.

B) C language is a structured programming language.

C) A program consisting of three basic structures can only solve simple problems.

D) modular design methods are advocated for structured program design

Analysis: C algorithms composed of three basic structures can solve any complicated problems.

(There are still many questions in the future, so I won't write them one by one)

 

Summary of questions and notes:

(1) algorithm: refers to the definite and limited steps taken to solve a specific problem. An algorithm in C language is implemented using functions, that is, a C language program can implement multiple algorithms.

 

(2) The algorithm has five features: 1. Poor 2. deterministic 3. Feasibility 4. Zero or multiple inputs 5. One or more outputs

 

(3) Algorithm Description: 1. flowchart 2. Box diagram (such as N-S diagram) 3. pseudocode 4. text description 5. program code Description

 

(4) computers cannot directly process C language programs and can only process binary code.

 

(5) Each C language file or function can be compiled separately, but only the main function can be executed.

  • 1.2 program composition, main function and other functions

(1) which of the following statements is false:

A) during the running of the C program, all calculations are carried out in binary mode.

 

B) All C Programs can run only after the compilation link is correct.

 

C) C. All computers run the program in decimal format.

 

D) In C program, character variables store the ASCII values of characters.

 

Analysis: C computer programs are compiled into binary code and executed by the computer.

 

(2) which of the following statements are true:

A) In the C program, the position of the main function is fixed.

 

B) all functions in the C program can be called to each other.

 

C) Each C program file must contain a mian function.

 

D) Another function cannot be defined in functions of the C program.

 

Analysis: The main function D can call other functions in the program, while other functions cannot call the main function.

The C language specifies that a function cannot be defined within the function.

(There are still many questions in the future, so I won't write them one by one)

Summary of questions and notes:

 

(1) The keyword sizeof is used to test the memory space occupied by different types of variables, and the number of bytes returned. Sizeof (memory testing operator)

 

 

(2) In the C language, it is stipulated that nested calls of functions are allowed, that is, recursive calls.

 

 

(3) in C language, there cannot be a process concept.

 

 

(4) in C language, functions can be compiled separately and can exist in the form of individual files.

 

 

(5) use functions as program modules to modularize the C program. A program consists of multiple functions. Each function can implement a specific function and implement modular design of the program, therefore, C language uses functions to implement software modularization.

 

 

(6) The location of the called function is not directly related to the call.

 

  • 1.3 program annotation, writing format and C Language Style

 

 

(1) which of the following four programs is completely correct:

A) # include <stdio. h>

Main ();

{/*/Programming

/*/Printf ("Programming! \ N ");}

B) # include <stdio. h>

Main ()

{/* Programming */

Printf ("Programming! \ N ");}

 

C) # include <stdio. h>

Main ();

{/* Programming */*/

Printf ("Programming! \ N ");}

 

D) # include <stdio. h>

Main ();

{/* Programming */

Printf ("Programming! \ N ");}

 

Analysis: The End of B main () is not followed by a semicolon (;). It is stipulated that nesting "/*" and "*/" cannot be performed between comments "*/".

 

(2) which of the following statements are true:

A) The writing format of C program is strict. Only one statement can be written in one row.

 

B) A simple C statement must end with a semicolon.

 

C) the comments in the C language program must be written in the same line as the statements.

 

D) Comments in C Programs can only appear at the beginning of the program and after the statements.

 

Analysis: B C language is free to write. Multiple statements can be written in one row. One statement can also be written in the same row, and one or more lines can be written.

Each statement and data definition must end with a semicolon.

C language programming has a lot of portability and can be stored in multiple program files.

(There are still many questions in the future, so I won't write them one by one)

Summary of questions and notes:

 

(1) The program can contain one or more structures, not three structures, and these three basic structures can solve complex problems and small-scale problems.

 

 

(2) The use of the goto statement will make the program prone to errors and difficult to read.

 

 

(3) spaces are not allowed in numeric constants.

 

 

(4) A plus sign (;) must be followed by a C statement. A no-plus sign cannot be considered as a C statement.

 

  • 1.4 identifiers, constants, and variables

(1) The following options are invalid identifiers:

A)

 

B) &

 

C) print

 

D) _ 00

 

Analysis: The B identifier must meet the requirements of ~ Z and ~ Z, number character 0 ~ 9 and underline. The digit cannot start with or be a keyword. The case is two different characters.

 

(2) which of the following options can be used as a data constant:

A) 115L

 

(B) 0018

 

C) 1.5e1.5

 

D) o115

 

Analysis: A data constant may have: 1.10 hexadecimal 2.8 hexadecimal numbers (numbers 0 ~ 7) 3.16 hexadecimal 4. index method (the index must be an integer)


(There are still many questions in the future, so I won't write them one by one)

Summary of questions and notes:

 

(1) variable refers to the amount of variable values that can be changed while the program is running.

 

 

(2) in C language, no logic type is defined. 0 indicates false, and non-zero indicates true.

 

 

(3) Symbolic constant: in C, a symbolic name is used to represent a constant, which is called a symbolic constant. Generally, macro definitions are used in programs to define symbol variables.

 

 

(4) The identifier is the variable name, function name, array name, file name, type name, and so on in C language.

 

 

  • 1.5 and 1.6 integer data and real constants and variables

(1) In the following options, a valid set of C language numerical constants are:

A) 12.0Xa23 4.5e0

 

B) 028. 5e-3-0xf

 

(C). 177 4e1. 5 0abc

 

D) 0x8A 10,000 3. e5

 

Analysis: In the exponential form of A floating point data, the C language specifies that the letter e or E must have A number before and the index after e or E must be an integer.

 

(2) The valid real constants in the following options are:

A). 914

 

B. 3.13e-2.1

 

C) 0

 

D) 2.0*10

 

Analysis: A Real-type constants are also called real numbers or floating-point numbers. In C, a real constant can be expressed in decimal or exponential form. 1. decimal form: a real number representation composed of digits and decimal points. For example, 0.345,. 123, and 0.0 are valid real numbers. This form must have a decimal point. 2. exponential form: in C, "e" or "E" is followed by an integer to represent a power function with a base 10. Note that the C language requires a number before the letter e or E, and the exponent after e or E must be an integer.

(There are still many questions in the future, so I won't write them one by one)

Summary of questions and notes:

 

(1) variables can be defined anywhere in the program and belong to different variables.

 

 

  • 1.7 character constants and character Variables

(1) which of the following statements is correct:

A) char A = 65 + 1, B = 'B ';

 

B) int a = B = 0;

 

C) float a = 1, * B = & a, * c = & B;

 

D) double a = 0.0; B = 1.1;

 

Analysis: A is not allowed to declare the type of the variable and assign values. It must be defined separately and assigned values. The C language allows multiple variables of the same type after a type description. variables must be separated by commas (,) instead of semicolons.

The computer stores the ASCII code corresponding to the ginger character in its binary format.

 

(2) The invalid C-language character constants in the following options are:

A) '9'

 

B) '\ 09'

 

C) '\ x09'

 

D) '\ x9d'

 

Analysis: A character constant of B represents a character in the ASCII character set. It is enclosed by single quotation marks in the program. It can also be an escape character. The Escape Character is also called a backslash character, these character constants always start with a backslash and follow a specific character to represent a specific ASCII character. These character constants must also be enclosed in a pair of single quotes, the number of octal segments after the backslash can start with 0, but cannot contain 8 or 9 characters. The hexadecimal format after the backslash can only start with the lowercase letter x.

(There are still many questions in the future, so I won't write them one by one)

Summary of questions and notes:

 

(1) Each character variable is assigned a content space of one character and can only store one character.

 

 

(2) The three-byte octal character '\ ddd' represents an ASCII character. It can also be '\ xhh' in hexadecimal notation to represent an ASCII character.

Take a break and wait for the next exam to take a note ..........

Related Article

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.