Basic syntax of C programming
You already know about the basic structure of the C program, now you will easily understand the basic blocks in the C language.
The Token in C
In C language, there are many different tokens and a token can be a keyword, an identifier, a constant, a string or a character. For example, the following C command line includes the following 5 tokens:
printf ( "Hello, World! n" );
Separate tokens are as follows:
printf ( "Hello, World! n" ) ;
Semi-colon ; in C
Program C, semicolon is part of the command end. In fact, each command in C must end with a semicolon. It informs the end of a logical attribute.
The following example is 2 commands:
printf ( "Hello, World! n" ); return 0 ;
Comment in C
The comment is the same as the help in C program and is ignored by the compiler. It starts with / * and ends with * / as below:
/* Day la chuong trinh C dau tien */
You cannot add a comment section inside this comment section.
Identifier in C
An identifier in C is a name used as a user-defined variable, function, and component. An identifier can start with characters A through Z, a to z and underscore (_) and 0 to 9.
C does not allow signs such as @, $, and% in identifiers. C is a language that distinguishes lowercase letters - uppercase letters . Therefore, QTM and qtm are two different identifiers in C. Here are a few valid identifiers:
nam hoangminh abc ha_noi a_123 sinhvien _hocphi j d23b5 nhanVien
Keywords in C
Below is a list of keywords that are reserved in the C language. Identifiers or variables, constants cannot name the same as the keywords below, otherwise the program will report an error.
auto else long switch break enum register typedef case extern return union char float short unsigned const cho ký hiệu không thể thực hiện goto sizeof volatile default if static khi có số struct _Packed doubleWhite space in C
A line may contain spaces, possibly comment lines, known as white lines when the same compiler is ignored when compiling.
A space in C can be a blank paragraph, tab, newline (new line) or comment. A space divides a part of a command into parts and helps the compiler distinguish a component in a command, such as int, end the component, and start the next component as follows:
int diemthi ;
There must be at least one character space between int and diemthi for the compiler to understand and distinguish them. On the other hand, see the command below:
luong = luongcoban + phucap ; // tinh tong luong
There is no need for a space between the space and the = sign, or between = and luongcoban.
According to Tutorialspoint
Previous article: Basic C program structure
Next lesson: Data type in programming C
You should read it
- How to find the SID (Security Identifier) for a user account in Windows
- Basic Java syntax
- How to Define, Add, and Subtract Matrices in MATLAB
- How IP addresses work
- The world's 5 most annoying 'programming languages'
- 2 simple ways to view and read MAC addresses on Windows 10 computers
- How to Get the UDID of your iPhone, iPod or iPad
- What is Facebook Token? What to get FB Token How to get fast FB Token
- What is a token?
- The importance of keywords - Keywords
- How to hide comments on Facebook with keywords
- Instructions on how to login Facebook with Token
Maybe you are interested
How to use the file search command on Windows, find saved files
Why is tldr command better than man command in Linux?
Should I use PowerShell or Command Prompt?
What to do when open command window here does not appear?
How to switch users on the Linux command line
How to fix Mac Homebrew error 'zsh: command not found: brew'