×

C Tutorial

C Basics

C Data Types

C Input/Output

C Operators

C Conditional Statements

C Control Statements

C Strings

C Functions

C Arrays

C Structure and Unions

C Pointers

C Preprocessor Directives

C Command-line Arguments

C File Handlings

C Graphics

C Advance Topics

C Tips and Tricks

C Important Topics

C Practice

C Tokens

C tokens are the smallest & individual words/characters, in other words these are the smallest building blocks which are used to write a program.

C tokens are divided into following categories:

  1. Keywords
  2. Identifiers
  3. Variables
  4. Constants
  5. Literals
  6. Operators
  7. And special characters

Keywords

Keywords are the reserved words in the C Compliers, we can not change the meanings of them, these are the words which have predefined meaning in the compilers.

C Language has 32 keywords, which are:

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

Identifiers

An identifier is the name of variable, constant, array, structure, functions etc. These are the user defined name which is used to define a name of particular memory location or particular data types.

Here are some of the rules to define an identifier:

  • An Identifier must start with a character or underscore.
  • Only 32 characters are allowed as an identifier name.
  • Spaces are not allowed in the identifier name.
  • A keyword can not be use as the identifier name.
  • Characters, digits, underscores are allowed in identifier name.
  • And the most thing is, An Identifier must be meaningful or descriptive
  • .

Some of the example of valid identifiers:

name, studentName, std_name, _age, myAge, percentage, salaryInformation, details1

Some of the example of vinvalid identifiers:

Std name, 1age, 0salary std-name, std*name

Variables

Variables are the name used to represent a memory location, which represent predefine or customize data type. A variable’s value can be change any time during program’s execution.

int num;
float myCity;
char *name;
int cities[100];    
    

Here num,myCity,name, cities are the variables.

Constants

Consonants are the name of those memory blocks, which are not changeable. A constant’s value is fixed during program’s execution.

const keyword is used to declare a constant.

A constant must be initialized with declaration.

#include <stdio.h>

int main()
{
    const int num = 100; // integer constant
    const float a = 1.23f; // float constant
    const char gender = 'M'; // character constat
    const char text[] = "includehelp.com"; // string constant

    printf(" num=%d \n a=%f \n gender=%c \n text=%s\n", num, a, gender, text);

    return 0;
}

Output:

num=100
a=1.230000
gender=M
text=includehelp.com    

Literals

Literals are the values which assigned to the variables of constants in other words we can say these are independent values in the program.

10      - Integer literal
1.23	- Double literal
1.23f	- Float literal
‘A’     - Character literal
“Hello”	- String literal
0xAF	- Hex literal
0123	- Octal literal
0b1100	- Binary Literal    

Operators

Operators are the special symbols which tell to the compiler to perform some mathematical or logical operation.

For examples: +, -, *, <<, ==

We will discuss these operators briefly in next chapter.

Special Symbols

There are some special symbols in c which play an important role to design a programs.

Symbols are:

~ 	Tilde
! 	Exclamation 
# 	Hash 
$ 	Dollar
% 	Modulus 
^ 	Caret
& 	Ampersand 
* 	Asterisk 
(  	Left parenthesis 
) 	Right parenthesis 
_ 	Underscore  
+ 	Plus sign 
| 	Pipe
\ 	Backslash
`	Apostrophe
- 	Subtract Sign
= 	Assignment Operator
{ 	Left brace
} 	Right brace
[ 	Left bracket
] 	Right bracket
:	Colon
" 	Quotation mark
; 	Semicolon
< 	Less than
> 	Greater than
? 	Question mark
, 	Comma
. 	Period (Dot)
/ 	Slash    

C Language Tutorial »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.