C tokens indentifiers keywords

C tokens identifiers and keywords

Social Shares
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

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.

#include

int main ()
{
printf ("Example of C tokens");
printf ("%d", 5);
}

C Tokens are of 6 types. Their list is being given below.

  1. Identifier.
  2. Keyword.
  3. Constant.
  4. Variable.
  5. String.
  6. Operator

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 tokens

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.

Alphabet

In Alphabet characters, you can use Z to uppercase and A to z lower case characters.

Digits

In Digits, you can use any digit from 0 to 9.

Special characters

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.

Identifiers

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.

  1. In Identifiers @,%, – characters are not allowed.
  2. C is case sensitive. Therefore age and Age are different identifiers.
  3. In identifiers, you can not use operators.
  4. You can either start the Identifier with either character or underscore. The identifier cannot be started from the digits.
  5. 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.

 

Example
_age // Valid

2name // Invalid

Emp-name // Invalid

Emp_2_age // Valid

Keywords

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.

auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while

C tokens

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.

  1. Using #define.
  2. Using Const keyword.

 

C variables

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.

 

C tokens

 Strings

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.

 

Operators

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.


Social Shares
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

7 comments

  1. Good Day,
    I studied your recent post, really enjoy lot and I hop u will deliver more post such like, I appreciate your ideas, keywords and approach to write above post, meanwhile it reduces my boring and divert my attraction more and more, so I please request you that write more articles in way to attract me and publically good. For more audience I will approach it and market to my community,

    Thanks to given me time.

Leave a Reply

Your email address will not be published. Required fields are marked *