☰ Topics



× Home Introduction Structure of program Variables and keywords Constants Data Types Operators Statements Functions Storage Classes Array Structure Pointer Union Strings Header Files

Variables and Keywords

Character Set

A character refers to the digit, alphabet or special symbol used to data representation.

  1. Alphabets: A-Z, a-z
  2. Digits: 0-9
  3. Special Characters: ~ ! @ # $ % ^ & * ( ) _ + { } [ ] - < > , . / ? \ | : ; " '
  4. White Spaces: Horizantal tab, Carriage return, New line, form feed

Identifier

Identifier is the name of a variable that is made up from combination of alphabets, digits and underscore.

Variables

Variable is a name of a memory location where we can store any data.

Local Variables

Local Variables are declared within the body of a function, and can only be used within the function only.

      Void main(){
        int a,b,c;
      }

      void func(){
      int x,y,z;
      }
    

Here a,b,c are the local variable of void main() function and it can't be used within fun1() function. And x,y and z are local variable of fun1().

Global Variables

A global variable declaration looks normal, but is located outsidde any of the program's function. This is usually done at the beginning of the program file, but after preprocessor directives.

    int a,b,c
      Void main(){

      }

      void func1(){

      }
    

Here a,b,c are globar variables, and these variable can be accessed (used) within a whole program.

  1. keywords are the sustem defined identifiers.
  2. All the keywords have fixed meanings that do not change.
  3. White space are not allowed in keywords.
  4. keyword may not be used as an identifier.
  5. it is strongly recommended that keywords should be in lowed case letters.

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

Escape Sequence Characters (Backslash character constants) in C:

C supports some escape sequence characters that used to do special tasks. These are also called as 'Baclslash characters'. Some of the escape sequence characters are as follow:

\n - New line
\b - Backslash
\t - Horizantal Tab
\f - Form feed

Next Topic ➤