C tutorial- Tokens and keywords in C Programming language

Programming languages or concepts
0

Tokens and Keywords in C

 In C tokens, identifiers and keywords are the basics in a C language. All are listed in one by one as followed.
C-Tokens:-
   C Tokens are the basics building blocks in c Language which are constructed together for build a program.
  In C each and every smallest individual part of C Programming in known as C - Tokens.

Thery are six types of C - Tokens in C

1) Keywords.              (eg.while,int,etc)
2) identifiers.              (eg.main, total,etc)
3) Contents.                 (eg.10,99)
4) String.                      (eg."Hello","Saurabh",etc)
5) Special symbols.    (eg.(),@,etc)
6) Operators                (eg.+,*,/,-,etc)


Keywords in C Programming Language:-

  •    Keyword is pre define words in C compiler.
  •     Each keywords is meant to performs a specific function in C programming.
  •    Keywords are not a user defined,we can't used a variable as keyword.
  • C Language can support a 32 keywords they are listed below.
  • Keywords are predefined, reserved words in C language and each of which is associated with specific features. These words help us to use the functionality of C language.
  • Keywords are words that have special meaning to the C compiler.
  • A keyword is a reserved word. You cannot use it as a variable name, constant name, etc. There are only 32 reserved words (keywords) in the C language.

Keywords in C Programming

auto

double

int

break

else

long

case

enum

register

char

extern

return

const

float

short

continue

for

signed

default

goto

sizeof

do

if

Static

struct

switch

typedef

union

unsigned

void

volatile

while

 


Description of all Keywords in C :

    auto
The auto keyword declares automatic variables. For example:

auto int var1;
This statement suggests that var1 is a variable of storage class auto and type int.

break and continue

The break statement terminates the innermost loop immediately when it's encountered. It's also used to terminate the switch statement.


switch, case and default

The switch and case statement is used when a block of statements has to be executed among many blocks.

Ex:

switch(expression)
{
    case '1':
    // statements  1
    break;
    case '5':
    // statements  5
    break;
    default:
    // statements ;
}


char

The char keyword declares a character variable. 

For example:

char alphabet;

const

An identifier can be declared constant by using the const keyword.

const int a = 5;


double and float

Keywords double and float are used for declaring floating type variables. 
For example:

float percentage;
double MRP;

if and else

In C programming, if and else are used to make decisions.

if (i == 1)
   printf(" True")
else
   printf(" False")


enum

Enumeration types are declared in C programming using keyword enum. For example:

enum pack
{
    hearts;
    spades;
    clubs;
    
};


for

There are three types of loops in C programming. The for loop is written in C programming using the keyword for.

  For example:

for (i=0; i< 5;i++)
{
  printf("%d ",i);
}


goto

The goto statement is used to transfer control of the program to the specified label.

int

The int keyword is used to declare integer type variables.

For example:

int number;

Post a Comment

0Comments

Post a Comment (0)
close