C Language Programming Basics

C Language Programming Basics

··· Exam Countdown: 36 Days ···

◣Attention Candidates◥

Scan to Join the Preparation Group for Further Studies

Courses/Exam Information/Materials/Benefits, one-on-one Q&A in the group!

C Language Programming Basics

C Language Programming Basics
Key Point 1: Characteristics of C Language Structure

1. A C program consists of functions, and there must be exactly one function named main.

2. A C language function consists of two parts: the function declaration and the function body.

(1) The function declaration includes the function name, function type, parameter names, and parameter types.

(2) The function body is the part within the curly braces.

3. The main() function: When a C program runs, it always starts from the main() function and ends in the main() function.

4. The formatting of a C program is flexible: a statement can be written over multiple lines, using \ as a continuation character.

5. Every statement in the program must end with a semicolon.

6. The C language itself has no input/output statements: these are completed by library functions such as scanf() and printf().

7. Comments can be added anywhere in a C program to improve readability. Comment statements are not executed by the program and cannot be nested. Multi-line comments use /**/, while single-line comments use //.

C Language Programming Basics
Key Point 2: The Development Process of C Language

Developing a C language program involves four steps: editing, compiling, linking, and running.

A C language program can be used on any architecture’s processor, as long as the processor has the corresponding C language compiler and libraries, and then the C source code can be compiled and linked into a target binary file for execution.

1. Preprocessing: Input the source program and save it as a .C file.

2. Compilation: Translate the source program into an object file (.OBJ file).

3. Linking: Generate an executable file (.EXE file) from the object file.

4. Running: Execute the .EXE file to obtain the results.

C Language Programming Basics
Key Point 3: The Main Function

A C program has exactly one main function, which is the main function.

A C program executes the code within the main function, which is the only entry point in C language.

For example:

#include<stdio.h> //Include the standard input/output library

int main(){ //main must be lowercase, and () cannot be omitted; program entry.

printf(“Hello, World!\n”); //Each statement ends with a semicolon

return 0; //Return value of main(); program ends.

}

Here, the int before main indicates the type of the main function; return is the return value of the function, which varies according to the function type.

C Language Programming Basics
Key Point 4: Conversion of Number Systems

Convert decimal to binary, octal, and hexadecimal: For the integer part, divide N and take the remainder; for the fractional part, multiply N and take the integer part.

Convert binary, octal, and hexadecimal to decimal: Use polynomial expansion.

C Language Programming Basics

Come and join the editor to participate

Course Consultation: 13111003278

Leave a Comment