Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Introduction to C
History of C Language
C Variables
Variables Types in C
C Identifiers
C Operators
C Comments
ASCII Value C
Constants C
Features of C
Install C Language
Start C Program
Compilation in c
printf() and scanf()
C Data Types
C Keyword
Format Specifier C
Format Specifier part2
Escape Sequence C
Tokens in C
Boolean in C
What are literals?
 


  

 
Variables Types in C
Question Posted on 17 Aug 2020

Home >> Tutorial >> C Language >> Variables Types in C


Variables Types in C
As per i define below there are 5 types of variables available in C:
(1)local variable
(2)global variable
(3)static variable
(4)automatic variable
(5)external variable

(1)Local Variable


When we declared variable inside the function or block is called a local variable. And we usually declared at the start of the block.


Local Variable
We must have to initialize the local variable before it is used.


(2)Global Variable


When we declared variable outside function or block is called global variable. And any of function can change value of global variable. And it is available to all the functions. And we usually define at the start of the block.



Global Variable

(3)Static Variable


When we declare variable with static keyword is called static variable. It retains its value between multiple function calls.


Static Variable
If we call function many times the local variable will print the same value for each and every function. In above example local variable alwasy remains 11. But when we declare static variable then it will be incremented in each function call 11,12,13 and so on.

(4)Automatic Variable


All variables in C that are declared inside the block, are automatic variables by default. We can explicitly declare an automatic variable using auto keyword.


Auto Variable

(5)External Variable


When we need to share a variable in multiple C source file then we need to use exteranl keyword. Below is the example to declare the extern variable.
Below we have define two file one to declare external variable. and in 2nd file we use external variable .


Extern Variable





Other Important Questions
Features of C
Introduction to C
History of C Language
Install C Language
C Variables







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |