Subscribe Us

C Tokens , Identifiers , Keywords and rules for Identifiers - smartduniya

In this post  we will be talking about C Tokens Keywords, Identifiers and Rules for Identifiers in C programming language.

C Tokens , Identifiers , Keywords and rules for Identifiers

 At the end of this post, you will be able to answer these questions. So let's start talking about C Tokens. So before talking about c tokens, let's get to the meaning of tokens first.

 So what are tokens actually in c programming ?

 In the outside world, tokens refer to something serving as an expression for something else or they refer to sign or symbols. In the passage of text, words or the punctuation mark are called tokens.

 Similarly in c program smallest individual units are called c tokens and there are six type of C tokens.

They are keywords, identifiers, constants, strings special symbols, operators and every statements in c program consists of c tokens.

 C tokens are like building blocks of c programs and these blue colored words are example for their respective c tokens.

So let's start talking about each of these C tokens in detail. So the first c token which we are going to talk about in detail is keyword.

 So what are keywords in C programming ?

keywords are predefined words which have some meaning associated with them and those meaning cannot be changed and keywords are always written in lowercase.

 It is because c language is case sensitive language. What it means is a word in c program written in upper case and lowercase are interpreted as two different words.

For example while writing a program if I mention this keyword called float in capital later then the functionality associated with this keyword will be lost and this keyword called float will no longer act as a keyword. So while writing a c program you have to make sure that you mention these keywords in lower case and yeah these are some of the keywords which c language supports and in the next I'll show you guys how and when to use each of these keywords but for now what you need to keep in mind is these are the keywords and while writing a c program you must mention them in lower case in order to avoid compilation error. Now let's move to discussing about identifiers.

So what are Identifiers in C programming?

 Identifiers are user defined words and they basically refer to the name of variables, function and arrays and these are some of the rules which we need to abide with while choosing the name for variable, function and arrays.

Rules for Identifiers in C programming:

So let us start talking about each of these rules in detail . The first rule says that identifier should begin with an alphabet or underscore. it should not begin with digits.

Second rule says that identifiers would consist of only letters digit or underscore, it should not contain any special characters like ampersand, percent sign, asterisk character , etc at any position of the identifier.

The third rule says that the maximum length of the identifier should be31.It should not exceed this number.

The fourth rule says that the keywords cannot be used as an identifier. It is because keywords are pre defined words and they already have meaning associated with them. So keywords cannot be used for purpose other than for which they have been defined. So keyword cannot be used as an identifier.

The last rule says that identifier should not contain white space in c program. White space refers to blank space. So well declaring a variable or choosing the name for variable, function, it should not contain whitespace. What it is trying to say is when we declare a variable or the function or array which consists of two or more than two words then there shouldn't be any space in between them.

For example if I need to declare a variable called "sum of two numbers" then there should not be any space between some, of and two numbers but we can use this underscore to separate each of those words(sum_of_two_numbers).

So identifier should not contain white space. Otherwise it will show compilation error and it brings me to an end of this post.

I will deal with rest of the tokens in upcoming post and in the next video I will show you guys what errors compilers show when you declare identifiers going against each of these rules. So guys this was all about c tokens, keywords, identifiers and rules for identifiers.

If you like this post, keep your thumb up, share it as much as possible and yeah don't forget to stay updated. Thank you for reading!!! If you have any query comment below.  

Don’t forget to Subscribe our Blog to get update. Just put your email on subscribe box and hit subscribe button , next verify your email , it will be done.

You will get every single post when we will upload in Smartduniya.


Read More ..

How to write comment in C ?

How to write libery function, header file in C ?

How to write Printf() function in C ?

Post a Comment

0 Comments