C – Tokens

C – Tokens:
C – Tokens are small and each of every individual unit or parts in a program called tokens.
It has six kinds of tokens. There are
  • Keywords (eg: int, while),
  • Identifiers (eg: a, b),
  • Constants (eg: 5, 10),
  • Strings (eg: “Hello”, “Welcome”),
  • Special symbols (eg: (), {}),
  • Operators (eg: +, /,-,*)
1. Keywords:
  • It is pre-defined words in C. (i.e., Fixed words for creating programs in C)
  • List of keywords in C language: 
auto
double
int
struct
break
else
long
switch
case
enum
register
typedef
char
extern
return
union
const
short
float
unsigned
continue
for
signed
Void
default
goto
sizeof
Volatile
do
if
static
While
2.Identifiers:
  • Identifiers are user-defined words in c program such as variable name, function name, array name, and etc.
3.Constants:
  • It is a fixed value in C.
  • But it can be changed during it’s before execution.
  • Users can also create constant throw syntax.
Syntax:
Const data_type variable_name = value;
For example:
The pi(π) value is standard value i.e. 22/7 = 3.14.
4.String:

  • Strings are collections of characters or alphabets i.e. words
  • It is used to display for users.
5.Special symbols:
It has a special built-in meaning in the C language. 


Expression
Symbols
Asterisk
*
Assignment
=
Ampersand
&
Brackets
[]
Braces
{}
Comma
,
Double-quotes
Front lash
/
Parentheses
()
Pre-processor
#
Semi-colon
;

1.   6.Operators:
Operators are symbols and used to perform some mathematics operations.
Six kinds of operators,
1.      Arithmetic operators(+,-,*,/,%,++,--)
2.     Relational Operators (==,!=,<=,>=,<,>)
3.     Logical Operators (&&,||,!)
4.     Assignment Operators(=,+=,-=,*=,/=,%=)
5.     Conditional Operators (?:)
6.    Bitwise Operators(&,|,^,<<,>>)
Example:

#include<stdio.h>
#include<conio.h>
void main()
{
    const int a=5;
    const int b=10;
    int c;
    clrscr();
    c=a+b;
    printf("Addition of a and b value is: %d",c);
    getch();
}

Output:

Explanations:
  • Keywords - main,int,printf,clrscr,getch
  • Identifiers - a,b,c
  • Constants - a=5,b=10
  • String- printf(“Addition of a and b value is: %d”,c);
  • Special symbols-(),{,},;,”
  • Operators -=,+


Share:

No comments:

Post a Comment

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me