Variables in C Language


What Are C Variables?

1.A C variable is a named identifier associated with a location in computer memory that stores a value.

2.The value can be changed as the program runs.

For example: int age = 18;

Here, “age” is the variable name and “18” is the value assigned to it. The data type of this variable is “int” which stands for integer.

In C, there are different types of variables (defined with different keywords), for example:

1.intstores integers (whole numbers), without decimals, such as 123 or -123

2.float – stores floating point numbers, with decimals, such as 19.99 or -19.99

3.char – stores single characters, such as ‘a’ or ‘B’. Char values are surrounded by single quotes

Declaring (Creating) Variables

Syntax

type variableName = value;

Ex.

Int a=20;

OR

Int a;

a=20;

 

Rules to Declare a Variable in C Language

  1. Variables must be given an appropriate name.
  2. Variables must begin with a letter or an underscore (_).
  3. Variables names cannot contain any special characters, such as #, @, or $.
  4. Variables names cannot contain spaces.
  5. Variables names must be unique.
  6. Variables must be declared before being used.
  7. Variables must be declared with a specific data type.
  8. Reserved words (such as int) cannot be used as Variable names

Leave a Reply

Your email address will not be published. Required fields are marked *

https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
About
Products
Subscribe

If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

    Applauz

    As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

    Subscribe

    If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

      Applauz

      As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

      Copyright by BOLD THEMES. All rights reserved.