Variables, Constants And Data Types in C Language

In this article we will learn about What is constant in C Language, Symbolic Constant in C, Variables And Constants In C Language, Types of Constants in C, Define Constant in C, Integer constant in C, Character Constant in C, Variables in C, C Programming VariablesRules for declaring variables in c, Variable declaration in C, Variable Declaration in C, Definition of Variable in C, Variable initialization in C, Variable declaration in C Programming language, Define Constant in C and Difference between constant and variable in c, Secondary Constants In C, Global Variable in C

We Will Also Discuss About the Difference Between Variables and Constants in C Language. Definition Of Constant in C LanguageConstant in C Language with Example.

Constants in C

We know that every software is developed for manage some type of data or information, that data or information is called constants.
Constants in C refer to fixed values that do not change during the execution of a program.
in other words, A constant is a value or an identifier whose value cannot be change in a program. For example: 2, 4, 3.9, 'c', "Hello World", etc.

When we write a program to calculate or find any desired output by using different type of operators get constants as output, For example if we creating a program for calculate factorial of a given number then in this program we will get 120 as our output for the input of 5, in this situation the output i.e. 120 is also an integer constant.

There are two types of constants in C:
  1. Primary Constants
    • Integer Constants
    • Real Constants
    • Character Constants
  2. Secondary Constants
    • Array
    • String
    • Pointer
    • Union
    • Structure
    • Enumerator

Constants in C Language

    Primary Constants are fundamental constants in C and the Secondary constants are the constants which is created with the help of Primary Constants. In this article we will discuss about the sub-categories of Primary Constants, Later on we will learn about Secondary Constants in our future articles.
    Integer Constants: Integer constants are numeric integer values, like 2, 5, 245, -540, 0, -3 etc.
    Real Constants: Real Constants are numeric fractional values, like 3.0, 8.5, 1964.98 etc.
    Note: 2.0 is a Real constant in C.
    Character Constants:   Any single symbol with single quote is called character constants in C, like 'a', '+', '2', 'B' etc.
    Note: '-3' is not a character constant because there is two symbols ( and  3)  similarly 3.0 is also not a character constant because it has three symbols ( 3, . and 0), there must be a single symbol under single quote to be a character constant in c. 

    Variable in C

    When we want to store any data or information in our computer, we store the data in storage devices like hard disk or SSD, similarly in Programming language a programmer store data for perform some operation on that data, the memory location on which the data is stored is known as Variables.
    In simple words, Variables are name given to memory locations. 

     Variables in C

    suppose, we are creating a program for finding the sum of two numbers, then we store that two numbers in memory that we can add them, that memory location on which these numbers are stored, known as variables.
    Let us take the above example of calculating factorial, if we are creating a program for calculate factorial of a given number, then we need to store the given number in memory so that we can perform some operation on that number for find factorial of that number. The memory location where we store that given number will called variable in this situation.
    Programmer can select a meaningful name for variables, like number, height, marks etc.

    Difference Between Constants And Variables in C 

    Constants are values that can not be change during the execution of a programs, whereas variables are name, which is given to memory locations. The value of variables can be change during the execution of a program. 
    Data Type Of Variables:
    A Variable in C language must be given a data type, which defines what type of data the variable will hold
    It can be:
    • int: Used To hold Integer value.
    • float: used to hold fractional numeric value.
    • double: used to hold fractional numeric value.
    • char: used to hold a character, only single character (symbol).
    Rules For Write name of Variable:
    • Variable name must not start with a digit.
    • Variables name contains alphabets, digits and underscore.
    • keywords are not allowed as variable name.
    Declaring, Defining and Initializing a Variable:
    - Declaratio of a variable must be done before they are used in the program. Declaration tells the compiler that what is the name of variable and what is its data type (which type of data that variable can store).
    Syntax: data_type variable_name;
    e.g. int age;
    - Initialization of a variable means to assign a value to the variable, this is done at the time of Declaration or after declaration.
    syntax: data_type var_name=value;

    Conclusion:
    So in this article we learnt about What is constant in C,Variables And Constants In C Language, Types of Constants in C, Define Constant in C, Integer constant in C, Character Constant in C, Variables in C, Rules for declaring variables in c, Variable declaration in C, Variable Declaration and Definition in C, Variable initialization in C, Variable declaration in C Programming language, Define Constant in C and Difference between constant, variable in c, Variable And Data Type In C Language.
    Now you are able to answer What is Integer Constant in C Language

    - Also Read: Basic Structure Of C or C++ Language | Introduction OF Java



    Thank You !!

    Tags: What is variable in C, what is Constant in C, What is Data Types in C, Types of Constants in C, Define Constant in C, Integer constant in C, Character Constant in C, Variables in C, Rules for declaring variables in c, Variable declaration in C, Variable Declaration and Definition in C, Variable initialization in C, Variable declaration in C Programming language, Define Constant in C and Difference between constant, variable in c, Data Type in C Language, Types Of Data in C, Data Types, Secondary Constants in C, What is variable in C, C Programming Constants, Constants And Variables In C Language