by Dinesh Thakur Category: Type And Variables

Main memory and CPU registers are the two memory locations where auto variables are stored. Auto variables are defined under automatic storage class. They are stored in main memory. Memory is allocated to an automatic variable when the block which contains it is called and it is de-allocated at the completion of its block execution.



 
by Dinesh Thakur Category: Type And Variables

A variable is an object whose value may change during execution of a program. It is a memory location used to store a data value. A variable name should be carefully chosen by the programmer so that its use is reflected in a useful way in the entire program. Variable names are case sensitive. Others are constants whose values cannot be changed during the execution of the program. However, their values have to be declared. In a program a variable may be declared as below.

 
by Dinesh Thakur Category: Type And Variables

A storage class specifies how the variables are used in the program.

 
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

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

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

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

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

 
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