Hello readers, You have learned “introduction of C programming language and how to install C++ compiler on the computer“. So today you are going to learn about C tokens, identifiers, keywords. So Let’s get started.
What are C tokens
The syntax of the C language has been followed by many other popular languages, so understanding C is very important for you. The C program is made up of tokens. Like, see a below-given program. This program is used in the correct order of C tokens and nothing but this. If you learn to use all the tokens of C, then you will become the expert of C.
int main ()
printf ("Example of C tokens");
printf ("%d", 5);
C Tokens are of 6 types. Their list is being given below.
If you look at this list, then in the above program, int, main, printf and software programming is cool etc. everything is tokens only. Not all of these tokens are going to tell you just about identifiers and keywords. You will be told in the next tutorials about the remaining tokens.
I understand that this concept will have become clearer what you have tokens. If so, let’s try to know about some C tokens in detail. But before this, you are going to tell about the character set of the C language.
C Character Set
In the C programming language, you write in the sequence of program characters. Like #include is made up of these statement characters. Here I have letters i, n, c, l and h. But it is not that you can use any character in the C program. For this, character set has been defined by C. Only characters in this set can be used in a C program.
In Alphabet characters, you can use Z to uppercase and A to z lower case characters.
In Digits, you can use any digit from 0 to 9.
In the special characters, you can use the following characters.
@ ; _ () etc.
Apart from these alphabet digits and special characters, you can not use any other character in the C programming language. This is what is called the character set of C.
This is another type of C tokens, Identifiers are those names that give you variables, constants and functions. There are some rules to give to these names that you follow. If you do not follow these rules then there is an error in the program. These rules are being explained further.
- In Identifiers @,%, – characters are not allowed.
- C is case sensitive. Therefore age and Age are different identifiers.
- In identifiers, you can not use operators.
- You can either start the Identifier with either character or underscore. The identifier cannot be started from the digits.
- You can start identifiers from A to Z, with both small and capital letters or any of the underscore. After this, you can use digits and other characters or underscore.
_age // Valid
2name // Invalid
Emp-name // Invalid
Emp_2_age // Valid
Keywords are also known as predefined C tokens or reserved words. C language provides 32 keywords. Every keyword has a special meaning. Every keyword has been defined to perform a specific task. The list of these keywords is being given below. These keywords are not being explained here. You will learn about these slowly in the tutorials that come in front.
Constants in C
This is another type of C tokens, Constants are those variables whose value does not change. Whenever you declare a constant, its value remains fixed during the execution of the program. If there is an attempt to change its value then there is an error in the program. These are also called literals.
Constants can declare you in 2 ways.
- Using #define.
- Using Const keyword
This is another type of C tokens, If you want to store data in the computer’s memory then for that you have to give a name for that memory location first. A variable memory contains the name of a location.
Let’s say this is your computer memory space. You want to store some data in it. Such as the age of a person etc. Before you can store data in computer memory, you will know exactly what kind of data you store. These define you through data types. Accordingly, you get space in memory. That is, if you have defined int, then by 2 bytes you will allow the compiler in memory.
Along with that, you have to define the name of that memory location too. So that whenever you want to access the memory stored in that memory location, you can access it by this name. This name is called variable only. Values of variables are variable. You can delete a value and enter another value. You can do it yourself manually or dynamically (during program execution) too.
This is another type of C tokens. There is no data type available to create strings in C language. We create char array to store the string in C programming language. Τherefore, in C, the character array is also called string. In the C language, the string is terminated from the null character (\ 0).
In C you can declare and initialize strings in two ways. In the first method, you create an array of a finite number and in each of its index, there is a character store of the string. The null character (\ 0) is stored in the last index of this array. It is necessary to do this. An example of this is being given below.
You can perform various types of operations on those variables by having values stored in the variables. For example, by having value store inside two integer variables you can perform the operation of addition and print the sum of values of those two variables. Similarly, you can do more with different operations variables.
To perform operations with variables, you have to use different operators. In this chapter, you are being told about such operators.
The variables that are used with operators in Operations are called operand.
I hope you understand how to use C tokens identifiers and keywords. If you understand then please share my hard work with your friends. Subscribe my newsletter for upcoming article’s updates direct in your mailbox. If you have any confusion or query then you can leave a message on my facebook page. At last, I would like to say please don’t forget to subscribe to my youtube channel. Thank you for visiting.