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 double

White 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

3.5 ★ | 2 Vote

May be interested

  • How to Start Programming in PythonHow to Start Programming in Python
    you want to learn programming? the process of getting used to programming can make you feel discouraged and think that you need to go to school seriously to do it. with some languages, this is sometimes true. but there are also many programming languages ​​that only take one to two days for you to grasp the basics of them. python [1] x research source is one such language. in just a few minutes, you can run a basic python program. read step 1 below to learn how.
  • Set of multiple choice questions about programming with P10 prizeSet of multiple choice questions about programming with P10 prize
    the programming questions below will give you lots of useful information. if you are interested in learning programming languages, the series of programming language topics will be very helpful for you.
  • CSS test with answer - Part 2CSS test with answer - Part 2
    a set of multiple choice questions about css programming for you to try and understand.
  • Set of multiple choice questions about programming with P7 prizeSet of multiple choice questions about programming with P7 prize
    current programming is no longer strange to us. programming work is becoming hot and more interested. please join the network administrator to learn about programming skills through multiple-choice questions below.
  • Set of multiple-choice questions on award-winning programming P5Set of multiple-choice questions on award-winning programming P5
    serializing programming tests, in the following article, readers will be able to expand their knowledge with more interesting questions. let's start.
  • Set of multiple choice questions about programming with P6Set of multiple choice questions about programming with P6
    the following network administrators will continue to send you interesting questions about programming. if you love this topic, then try your knowledge.
  • P13 programming set of multiple choice questionsP13 programming set of multiple choice questions
    you are a fan of programming languages ​​and want to learn more about this topic. to give you an interesting reading about programming, in this article, the network administrator will send you a good quiz about this topic. invite your reference.
  • Basic Markdown syntaxBasic Markdown syntax
    there are many reasons to use markdown, but the biggest reason is due to the convenience of using custom designed syntax to help you save time.
  • Set of multiple choice questions on programming with P3 prizeSet of multiple choice questions on programming with P3 prize
    invite readers to participate in testing knowledge with questions around the topic of the following programming of network administrator. the question set will have 10 questions with 4 answers, please choose the most accurate answer.
  • Set of multiple choice questions on programming with P16 prizeSet of multiple choice questions on programming with P16 prize
    multiple choice questions about programming will be the first piece of knowledge to help you get started with programming. invite your reference.