Skip to main content

Variable: Declaration, initialization and Usage


Variable

Variables are the names given to some memory location where a value is stored; the variable is corresponding to the data or value input in it.

source: http://diwo.bq.com/wp-content/uploads/2014/12/Variables-en-Arduino.jpg


RULES FOR DEFINING A VARIABLE / VARIABLE NAME:

  • · A Variable name should not have name of any KEYWORDS in C.
  • · A Variable name can be alphanumeric but should start with an Alphabet.
  • · A Variable name should not consist of any special symbol other than “_” Underscore Symbol. 
  • · A Variable should be defined before using it.

VARIABLE DECLARATION:

In this step, the variables are declared, this steps always occurs before using the variables.

FORMAT:



 EXAMPLE:



VARIABLE INITIALIZATION:

Providing a Value to any variable is called initialization.


INITIALIZATION AT THE TIME OF DECLARATION:


The variable can be given its value at the time of declaration.


USAGE OF VARIABLE:

Here is the example, to show how a variable is used in formulas to find out some values:




Comments

Popular posts from this blog

Basic Structure of 'C' Program and Printing Hello,World! in 'C'

The Basic Structure of ‘c’ Like most of the programming languages, C too has a structural approach and hence it has a basic structure. Here is the basic structure of a typical C program: 1)     DOCUMENTATION A Typical Program consist s of Documentation, in which the Details regarding the program and the programmer are written in comments. 2)    HEADER FILES: LINK TO THE C LIBRARY Header Files links the Various Library modules, classes to the program, Header files Includes methods from C Library with a “ #include ” command and the function name within < > symbols. E.g.: include<stdio.h> which includes Standard Input Output Methods to C Program. 3)    DEFINITION define directive is used to define a variable whose value stays same throughout the program. E.g.:   #define PI 3.14 4)   GLOBAL DECLARATIONS The Functions other than main () are declared here in global declaration section E.g.: ...

Keywords and Comments in C

KEYWORDS IN C For better blogs do comment your opinion and share the blog What are Keywords? Keywords are the words that convey a special meaning to the compiler. This means the meaning of every particular keyword is already defined to the compiler of the Language. There are total 32 Keywords in C Language and all have their meaning fixed to the compiler. These are the keywords in C. auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while The Keywords in Red are the data types they are used to define the data type of a variable. Example: int i; float f; char ch; long l; The Usage of these keywords will be covered as they arrive ...