News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Types of variable

Started by thiruvasagamani, Sep 22, 2008, 02:51 PM

Previous topic - Next topic

thiruvasagamani

Types of variable:

1.Normal variable or variable:

It can hold only value but not address.
int a = 25;
float b = 10.8;
char ch = 'g';
These contain values.
int a =25;
int b;
b = &a; // error
b =a ; // correct
Variable 'b' can hold only value but not address of 'a' , b = a is correct but not
b= &a

2. Pointer variable or pointer:

It can hold only address but not value, a pointer is nothing but address
int *p1;
float *p2;
char *p3;
* indicates that p1 , p2 , p3 are pointers , * is compulsory in pointer declaration .
p1 is a pointer to integer
p2 is a pointer to float
p3 is a pointer to character
p1 , p2 , p3 can hold addresses.
int * p = 1000; // error
A pointer can hold address but not value 1000. Pointer always takes 2 bytes of memory space(turbo c) but in Linux it takes 4 bytes , irrespective of type of pointer
sizeof( int *) = 2 bytes
sizeof( float *) = 2 bytes
sizeof( char *) = 2 bytes

3. pointer to variable:

int a = 25;
int *p ;
p = &a; ( or) int *p = &a;
Address of variable 'a' is stored in p. p is pointer to variable 'a' . p is address 1000, * p is value 25, &p is address of address that is 2000.
Thiruvasakamani Karnan


richardpeter

The C programming language has an extensive system for declaring variables of different types. The C language demands that you declare the name of each capricious that you are traveling to use and its type,, or class, before you actually try to do anything with it. The Programming language C has two main variable types :

- Local Variables
- Global Variables



sanju9956cs@gmail.com

sentence:
Don't begin variable names with underscore, however, since library routines often use such names.
If you happen to pick a name which ``collides'' with (is the same as) a name already chosen by a library routine, either your code or the library routine (or both) won't work. Naming issues become very significant in large projects, and problems can be avoided by setting guidelines for who may use which names. One of these guidelines is simply that user code should not use names beginning with an underscore, because these names are (for the most part) ``reserved to the implementation'' (that is, reserved for use by the compiler and the standard library).
Note that case is significant; assuming that case is ignored (as it is with some other programming languages and operating systems) can lead to real frustration.
The convention that all-upper-case names are used for symbolic constants (i.e. as created with the #define directive, which we learned about in section 1.4) is arbitrary, but useful. Like the various conventions for code layout (page 10), this convention is a good one to accept (i.e. not get too creative about), until you have some very good reason for altering it.
Deep sentence:
Keywords like if, else, int, float, etc., are reserved; you can't use them as variable names.
:police

yagnesh86

hi
These are variable supported by c language.
# 1 Basic types

    * 1.1 Signing
    * 1.2 Size
    * 1.3 Type qualifiers

# 2 Pointer types

    * 2.1 Pointers to pointers

# 3 Arrays

    * 3.1 Arrays of arrays
    * 3.2 Arrays of pointers
    * 3.3 Pointers to arrays
    * 3.4 Arrays as function parameters
    * 3.5 Array access of pointers

# 4 Functions
# 5 References

gaddam

bajrangi bhaijaan movie review and rating

Don't begin variable names with underscore, however, since library routines often use such names.
If you happen to pick a name which ``collides'' with (is the same as) a name already chosen by a library routine, either your code or the library routine (or both) won't work. Naming issues become very significant in large projects, and problems can be avoided by setting guidelines for who may use which names. One of these guidelines is simply that user code should not use names beginning with an underscore, because these names are (for the most part) ``reserved to the implementation'' (that is, reserved for use by the compiler and the standard library).
Note that case is significant; assuming that case is ignored (as it is with some other programming languages and operating systems) can lead to real frustration. bajrangi bhaijaan movie total box office collections
The convention that all-upper-case names are used for symbolic constants (i.e. as created with the #define directive, which we learned about in section 1.4) is arbitrary, but useful. Like the various conventions for code layout (page 10), this convention is a good one to accept (i.e. not get too creative about), until you have some very good reason for altering it.