What to learn about c language programming
What is C language?Introduction to C language.
C is a computer programming language that has characteristics of both high-level languages and assembly languages.
It can be used as a working system design language to write system applications or as an application programming language to write applications that do not depend on computer hardware.
Therefore, it has a wide range of applications, not only in software development, but all types of scientific research require the use of C, specific applications such as microcontroller and embedded systems development.
Language features:C is an intermediate language/C is a structured language/C is a full-featured language/C has a large scope of application/C is simple, compact, flexible and convenient/rich operators/rich data types/C is a structured language/less stringent grammatical constraints, large degree of freedom in program design/large scope of application, good portability.
Computer c language basics
Characteristics of computer c language
C language is one of the most popular and widely used high-level programming languages in the world. In the operating system and the system using the program and the need to operate the hardware, with C language is clearly superior to other high-level language, many large-scale application software are written in C. The main characteristics of C language are as follows:
1, C is a high-level language: it combines the basic structure and statements of high-level languages with the practicality of low-level languages.
2. C is a structured language: the distinguishing feature of a structured language is the compartmentalization of code and data, i.e., the parts of a program are independent of each other except for the necessary exchange of information.
3. C is a full-featured language: it has a wide range of data types and introduces the concept of pointers, which makes the program more efficient. And the calculation function, logical judgment function is also more powerful, can realize the game for decision-making purposes.
4, C language is applicable to a wide range: suitable for a variety of operating systems, such as Windows, DOS, UNIX, etc.; also applies to a variety of models.
5, C language application pointer: can be directly close to the hardware operation, but the pointer operation of C does not do the protection, but also brings it a lot of insecurity. C + + in this regard to do the improvement, in the retention of the pointer operation at the same time and enhance the security.
6. D.M. Ritchie, founder of C. 6. C files consist of sequences of data: they can constitute a binary file or a text file Commonly used C IDEs are MicrosoftVisualC++, Dev-C++, Code::Blocks, BorlandC++, WatcomC++. Borland C++Builder, GNUDJGPPC++, Lccwin32CCompiler3.1, HighC, TurboC, C-Free, win-tc,xcode and so on.
Syntax structure of computer c language
1. Sequential structure
Sequential structure of the program design is the simplest, as long as the order of problem solving to write the corresponding statements on the line, it is the order of execution is the order of the top-down, in order to execute. Sequential structure can be used independently to form a simple complete program, the common input, calculation, output three-step program is a sequential structure.
2. Selection structure
The execution of the selection structure is based on certain conditions to choose the execution path, rather than strictly in accordance with the physical order of statements. The key to the selection structure of the program design method is to construct appropriate branching conditions and analyze the program flow, according to different program flow to choose the appropriate selection statement.
3. Loop structure
Loop structure can reduce the workload of repetitive writing of the source program, which is used to describe the problem of repeating the execution of a certain algorithm, this is the program structure of the program design that can make the most use of the strengths of the computer, the C language provides four kinds of loops, namely, goto loops, while loops, dowhile loops and for loops.
4. Modular program structure
The modular program structure of the C language with functions to achieve, that is, the complex C program is divided into a number of modules, each module is written as a C function, and then through the main function to call the function and the function to call the function to achieve a large-scale problem of the C program to write, and therefore it is often said that: C program = the main function + sub-function. Therefore, the definition of the function, the call, the value of the return to pay particular attention to the understanding and application, and consolidated through on-line debugging.
Computer c language basics
【Knowledge 1】 C program
C program structure has three kinds of: sequential structure, cyclic structure (three loop structure), selective structure (if and switch)
【Knowledge 2】main function
Each C program main function is there and only one. Read the program from the main () entry, and then from the top order to read down (hit the loop to do the loop, hit the selection to do the selection).
【Knowledge Point 3】 Storage Forms
Computer data is stored in binary form in the computer. The lowest storage unit is the bit (bit), the bit is composed of 0 or 1. byte means byte, a byte = eight bits. The location where the data is stored is its address.
[Knowledge Point 4] comments
is a description of the program, can appear in any appropriate place in the program, comments from the “/*” to the end of the latest “* /”, any content in the intervening period will not be executed by the computer, the comments can not be nested. Comments can not be nested.
[Knowledge 5] Writing Format
Each statement must be followed by a semicolon, which is part of the statement. Multiple statements can be written in one line, and a statement can be written on more than one line.
[Knowledge 6] Identifiers
Legitimate user identifiers Exam:
Legitimate requirements are composed of letters, numbers, and underscores. It is wrong to have other elements.
And the first must be a letter or an underscore. It is wrong if the first is a number.
C identifiers are divided into three categories
(1) Keywords. They have a fixed meaning in the program, can not be used for other purposes. Such as int, for, switch, etc.
(2) Predefined identifiers. Pre-defined and have a specific meaning of the identifier. Such as define, include, and so on.
(3) User identifiers. User-defined identifiers according to the need to comply with the naming rules and not the same as the keywords.
Keywords are not allowed as user identifier numbers. maindefinescanfprintf are not keywords. The thing that confuses you about If is that it can be used as a user identifier. Because the first letter of ‘ in If is capitalized, it is not a keyword.
[Knowledge 7] Real Data
The legal forms of real data: fractional and exponential. Master to determine the legitimacy of the exponential form.
2.333e-1 is legal, and the data is 2.333 × 10-1.
Exam mnemonic: there must be a number before e and after e, and e must be an integer.
[Knowledge 8] Characters
The legal form of character data::
‘1’ is a character occupying one byte, and ‘1’ is a string occupying two bytes (containing a terminating symbol).
The ASCII value of ‘0’ is represented as 48, the ASCII value of ‘a’ is 97, and the ASCII value of ‘A’ is 65.
Character types and integers are close relatives:
chara=65;
printf(“%c”, a); output obtained: a
printf(“%d”,a); output obtained: 65
The general exam indicates the form of a single character error: ’65’ “1”
Characters are amenable to arithmetic operations, remember: ‘0’-0=48<
Uppercase and lowercase letters are converted in the following way: ‘A’+32=’a’ is generally 32 from each other.
[Knowledge 9] Integer data
Integer data is generally two bytes, character is one byte, double-precision is generally four bytes:
The exam will generally say that in the 16-bit compiler, or 32-bit system, the data will not be converted into a single byte, but the data is converted into a single byte. The first time I saw this, it was a 16-bit compiler, or a 32-bit system. When you encounter this situation, do not care,
the same questions. Mastery of the integer is generally two bytes, character type is a byte, double precision is generally 4 bytes on it.
[Knowledge 10] escape characters
The examination of escape characters:
In the program inta = 0x6d, is a hexadecimal number to the variable a Note that 0x must exist here.
In the program inta=06d, is an octal form.
In the escape character, ‘x6d’ is only legal, 0 cannot be written and x is lower case.
‘141’ is legal, 0 cannot be written.
‘108’ is illegal because 8 cannot occur.
[Knowledge 11] Arithmetic Operations
There are five arithmetic operators: +, -, *, /, and %. Both sides of the % symbol are required to be integers. If it is not an integer, it is wrong.
Three cases of rounding lost decimals: not rounding is to round off the decimal part.
1, inta = 1.6;
2, (int)a;
3, 1/2; 3/2;
[Knowledge 12] forced type conversion
will be converted into an arithmetic object of the specified type, the format of the (type name) expression
must be (int)a is not int(a). Note that there must be parentheses on the type.
Note the difference between (int)(a+b) and (int)a+b. The first is to transform a+b, and the second is to transform a and then add b.
[Knowledge 13] Assignment
If it is an expression, it must have a value.
Assignment expression: the expression value is the leftmost value, a = b = 5; the expression is 5, constants can not be assigned.
Compound assignment operators: note: a*=m+2 is a=a*(m+2)
Self-adding, self-reducing expressions: suppose a=5, ++a (the expression has a value of 6), a++ (the expression has a value of 5);
j=a++; is equivalent to j=a;a=a+1; and j=++a; is equivalent to a=a+1;j=a;.
Exam mnemonic: ++ in the front first add and then use, ++ in the back first use and then add.
[Knowledge 14] Comma Operations
Comma expression: the lowest priority level; the value of the expression comma the rightmost value of that expression.
The value of the expression for (2, 3, 4) is 4.
[Knowledge Point 15] Number System Conversion
Be sure to remember how binary is converted to decimal.
There is no 8 in octal, every 8 is rounded to 1. The value of 018 is illegal.
[Knowledge 16] Bitwise operations
There will be one or two exam questions.
C provides six kinds of bitwise operators: bitwise inverse ~, bitwise left shift <<, bitwise right shift >>, bitwise with &, bitwise iso|, bitwise or^.
General treatment: Almost all topics of bitwise arithmetic follow this process (first decimal to binary and then to decimal).
The rules of the different-or operation: 0 or 1 to get 1, 0 or 0 to get 0, 1 or 1 to get 0. It can be written as “same as 0, different as 1”.
In the absence of rounding data, << left shift by one means multiply by 2; >> right shift by one means divide by 2.
The rule of different-or operation: 0 or 1 gets 1; 0 or 0 gets 0; 1 or 1 gets 0.
College c language frameworks to comb through the basics to get a solid foundation
7 Steps to Editing in C Language Highly recommended
Step 1:Define the goal of the program
When you are before you start writing a program, you should have a clear idea of what you want the program to do. Consider the information that the program will need, the calculations and operations that the program will need to perform, and the information that the program should report to you. At this planning stage, you should think about the problem in terms of general concepts rather than some specific computer language terms. In short, all we have to think about is what the program is used for.
Step 2: Designing the program
When you have a conceptual idea of what the program needs to accomplish, you should decide how the program is going to accomplish it, what the user interface should look like, how the program should be organized, who the target user is, how much time you have to complete the implementation of the program, and so on.
This part is actually like writing an essay, when you think about what topic you want to write, then you have to list the outline of your essay, how many paragraphs you need, what techniques you need to use, what is written in each paragraph, and how much time you have in total to complete the essay. Just plan these out and list them as an outline and then realize them in order.
Step 3: Write the code
With a clear design for your program, it’s time to implement it by writing the code. That is, transforming your design ideas into C language. Here is where you really need to use C literacy. You can sketch your ideas on paper, but eventually the code must be entered into the computer. Typically, a text editor is used to create a file called the source code, which contains the C implementation of your program design.
Step 4:Compile
The next step is to compile the source code. However, the details of compilation depend on the programming environment, and you’ll see some common environments shortly below, so let’s start with a general idea of what we’re going to do.
As mentioned earlier, a compiler is a program whose job is to convert source code into executable code. Executable code is code expressed in the machine language of the computer. This language is made up of detailed instructions represented by numeric codes.C compilers are used to convert C into machine language.C compilers also add code to the final program from the libraries of C. The C compilers also add code to the final program from the libraries of C. The C compilers are used to convert the code from C to machine language. The library includes many standard routines for you to use, such as printf) and scanf(). The end result is an executable file that contains code that the computer understands and that you can run.
Step 5: Run the program
In general, an executable is a file that you can open and run directly. In general operating systems (such as WindowsLinux), to run a program, you just need to double-click on the file or right-click to open it to run it, which is an executable file. So how do you generate an executable file? For example, to run a program in a Windows environment with the QT compiler you can use the shortcut key Ctrl + R to generate the program and show the structure of the program, if you use the VisualStudio compiler is Ctrl + F5 to compile and run.
Step 6: Testing and debugging the program
It’s great that the program works, but sometimes it can run incorrectly. Therefore, you should check to see if there is an error in the program. This error is called a bug in computer jargon, and debugging is all about finding and fixing program errors. It’s natural to make mistakes in learning, and it seems likely that you will make mistakes in programming, so it’s a good idea to be prepared to think about how easy it is to make mistakes when applying what you’ve learned to programming. As you become a stronger, more skilled programmer, your mistakes will become more serious and less noticeable.
Step 7: Maintaining and Modifying Programs
After creating a program for yourself or for someone else, the program may have a wider application. If this is the case, you may find the need to make changes to it, that is, maintenance and modification of the program. I have to mention the role of code style and comments here, many people don’t like to write comments and their code style is extremely messy. But when you go to maintain someone else’s program, if he has not written comments, and a pile of code crowded together, then you may have a headache to death, just want to yell at the programmer to write this program. By people and their own, to develop a good programming style is a very good habit, after writing the program by the way marked with comments
What are the knowledge points of Chapter 1 Fundamentals of C Programming (Elementary) of the course C Programming?
What are the knowledge points of the first chapter of the course C Programming (Elementary)? -Character Variables, [Beginner] Lecture 8 – Type Conversion, [Beginner] Lecture 9 – Constants,.
What is taught in the C programming course?
The C Programming course is an introductory programming course that provides a basic understanding of programming by learning the basic syntax of the C programming language, laying the foundation for subsequent computer courses and object-oriented programming courses. Course content: C language program basic structure and related concepts, variables, functions, statements, if conditional statements, switch conditional statements, for loop statements, while loop statements, arrays, pointers, strings, structures. If you need to learn systematically, it is recommended that you choose Darnell Education.
Fundamentals of C Programming takes Standard C as the framework and VisualC++6.0 as the programming environment, and introduces the basic specifications, ideas and methods of C programming according to the principles of keeping close to the basics and being application-oriented. [Basic C Programming Course] Starting from cultivating students’ actual programming ability, it focuses on example teaching and practical exercises, highlighting key explanations and difficulty analysis.
The Basic C Programming course is clear in concept, comprehensive in content, and rich in examples and exercises. All the sample programs in the related materials give the analysis of algorithmic thinking and algorithmic steps, and give the results after debugging and running on the computer, and each program follows the standardized programming style, which is easy for students to understand and learn. If you are interested, click here to learn it for free