Skip to main content

What Are Variables in C language | Constants and Keywords in language

Variables Constants and Keywords in C language

Variables are the containers in C language which are used to store data in the program. Variables are the small memory blocks which holds some values in it.

Variables in c language : 

    What are variables in C language ?

   In C language, A variable is just like a container that contains values of different data         types. A variable is an entity whose value can be change.
     This means that to store any value we use variables in C language. These variables can e      imagined as the small memory blocks in which the data is stored of different types. The         variables are the one of important components of c language as it is used most                       frequently inside the programs of C language.

     For Instance In our Kitchen we have different containers in which we contain rice, dal,         sugar, salt etc. Similarly the variables stores value of a constant.
                Example :  int a = 9;
                                  int b = 3;
                                  int c = 67;
      In the above examples a, b, c are the variables and int is their data type (We will discuss       the data data type later in further posts) and '=' is assignment operator and 9, 3, 67 are            the values assigned to the variables.

      Rules for the naming of variables in C language : 
  •     First character of the name of variable should be an Alphabet or ( _ ) underscore.
  •     No commas or Blank spaces are allowed in the name
  •     No special symbols or characters are allowed other than ( _ ) underscore.
    Variable name in C language are case sensitive i.e. if we make a variable named cat              then we can also make another variable whose name can be CAT and we can store                different values inside them .

    What are Constants in C language ?

    An entity whose value does not change is called constants in C language. 
     In other words constants are the integers or the values which we put inside the                       variables.


    Types of Constants : 
    
    Primarily there are three types of constants in C language :
  1.     Integer Constant =>  An integer constant is a constant in which all       integers are included such as -1, -5, 3, 5, 7 etc.
  2.      Real Constant => A real constant is a constant in which all real numbers or floating point numbers are included such as 256.32, 3.5, 45.96, 132.5489 etc.
  3.       Character Constant => A character constant is a constant in which all alphabets and special characters are included such as 'a', '$', '@'
    A character constant must be enclsoed in single inverted commas.
    Keywords in C language : 

    A keyword in C language are the reserved words for C language programming. These         words are a part of the structure of a c language program. These words can never be used      for the variable or function or any other nomenclature in c program.
    These words are already known and understood by the C compiler.

    There are 32 Keywords reserved in C language :
    
    auto            double        int             struct
    break         long             else           switch
    case            return         enum        typedef
    char           register       extern       unuion
    const          short           float          unsigned
    continue    signed         for             void
    default       sizeof          goto           volatile
    do               static          if                while

Comments

Popular posts from this blog

C Programming Examples | C Examples | C programming Exercises, Practice, Solution

  Here are few very simple and basic C language programs with C programming examples that you will use to understand the basics very easily. Write a C programme to calculate area of a rectangle : #include<stdio.h> int main(){           Int l, b, area;           printf(“Enter length and breadth of a rectangle \n”);           scanf(“%d %d”, &l, &b);           area = l *b;           printf(“Area of rectangle is %d \n”, area);           return 0; } Write a C program to calculate area of a circle : #include<stdio.h> int main(){           float r, area;           printf(“Enter the radius of the...

Structure of C Program with Example | C Programming

In this post I will tell you the basic structure of C program  with example in C programming in very simple words. Our First C program : # include<stdio.h> int main() {            printf("Hello World");            return 0; } save te above program with file name "First.c" Note : Every C language file should be saved using .C extention name. Basic structure of a C program : All C programs have to follow a basic structure. The execution of a C program starts from the main() function. The C compiler starts execution from the main() function and executes each statement written inside the main() function line by line. Each instruction of a C program should be terminated by a semicolon ( ; ) i.e. every line of a C program ends with the semicolon ( ; ). 1.      Every program execution starts from the main( ) function. 2.   ...