by Dinesh Thakur Category: Type And Variables

Register variables are stored in the CPU registers. Its default value is a garbage value. Scope of a register variable is local to the block in which it is defined. Lifetime is till control remains within the block in which the register variable is defined.



 
by Dinesh Thakur Category: Type And Variables

Static variable is a special variable that is stored in the data segment unlike the default automatic variable that is stored in stack. A static variable can be initialized by using keyword static before variable name.

 
by Dinesh Thakur Category: Type And Variables

First, though there can be many declarations (and in many translation units) of a single ``global'' (strictly speaking, ``external'') variable or function, there must be exactly one definition. (The definition is the declaration that actually allocates space, and provides an initialization value, if any.)

 
by Dinesh Thakur Category: Type And Variables

If you might need large values (above 32,767 or below -32,767), use long. Otherwise, if space is very important (i.e. if there are large arrays or many structures), use short. Otherwise, use int. If well-defined overflow characteristics are important and negative values are not, or if you want to steer clear of sign-extension problems when manipulating bits or bytes, use one of the corresponding unsigned types. (Beware when mixing signed and unsigned values in expressions, though.) Although character types (especially unsigned char) can be used as "tiny'' integers, doing so is sometimes more trouble than it's worth, due to unpredictable sign extension and increased code size.

 
by Dinesh Thakur Category: Type And Variables

Enumeration is a data type, which is coded as enum, may be used to define user's own data type and define values that the variable can take. The enumeration type is an integral data type. This can help in making program more readable. enum definition is similar to that of a structure. Its syntax is as follows:



 
by Dinesh Thakur Category: Type And Variables

Generally in C program the function definition and calling takes the form as given below:

 
by Dinesh Thakur Category: Type And Variables

An arithmetic expression contains only arithmetic operators and operands. We know that the arithmetic operators in C language include unary operators (+ - ++ -- ), multiplicative operators (* / %) and additive operators (+ - ). The arithmetic operands include integral operands (various int and char types) and floating-type operands (float, double and long double).

 
by Dinesh Thakur Category: Type And Variables

Declaring variables tells the compiler the data type the variable is assigned and no storage area is allocated during this stage. It is possible to assign values during declaration itself. In order to see how this can be done let us see an example.



 
by Dinesh Thakur Category: Type And Variables

when a variable is not initialized in main function it contains garbage value. This can be well seen from the example below

 
by Dinesh Thakur Category: Type And Variables

Consider that we need to work with the colours in a rainbow, e. g., to paint a rainbow on the screen. We thus have to work with seven colours, namely, violet, indigo, blue, green, yellow, orange and red. These colours can be represented using integer values starting with 0. This enables us to use various program constructs such as conditions or loops to process these colours. However, programs written using such code often become difficult to understand as can be seen from the statement given below.

 

Page 2 of 4

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content