Showing posts with label Variables. Show all posts
Showing posts with label Variables. Show all posts

Monday, January 11, 2016

Variables

Void Type

Void type is defined using keyword 'void'. It's used to represent absence of data. For example, if a functions is declared with 'void' return type, it means that function doesn't return any values. But you cannot define a variable with 'void' type, program will not compile. You can declare void pointers though. 
Variables
In C programs, sometimes you may need to store some values so that you can later do some calculation or operation on the stored values. To hold these values we need variables. The variable can be considered as a type of identifiers that are used to represent some type of value or information in a designated portion of a program. A variable can be assigned different values in the course of its life span, i.e. the value stored in a variable may change. However, the type of data associated with a variable can never be changed.
Variable declaration
Declaration means associating a variable with some data type. Declaring variable will enforce that the variable can only represent values of already specified data types. A declaration has a specific format. Let’s consider following declaration as an example.
int number;
By this declaration, we are specifying that the number is a variable of data type integer. Until now, the variable number does not contain the value we want. The values can be assigned to the variable as follows