C

Fundamental concept of Problem solving
Introduction
Problem solving strategies
Program design & implementation
Introduction to C
Introduction to C
How to open C program code window
Description of C code window
Editing File
Saving and Running a program
The components of C language
Structure of C Program
A sample of C language program
C character set and keywords
C character set and keywords
The C character set
Identifiers
Key words
Data Types
Data Types
Primary Data Type
Secondary Data Type
Variables
Introduction
Rules for constructing variables names
Variable declaration
Assigning values to variables
Scope of variables: Local & Global
Constants
Introduction
Character constants
Integer constants
Real constants
Logical & String constants
C instruction set
Introduction
Type Declaration & Input/Output Instructions
Arithmetic Instructions
Control Instructions
Operators
Introduction
Arithmetic operators
Relational operators
Logical operators
Increment & Decrement operators
Bitwise operators
Conditional & ternary operators
The comma operators
Size of operator
Assignment operator
Type modifier
Expressions
Evaluation of expression
Automatic type conversion
Basic Input/Output
Introduction
Console I/O function
Disc & Port I/O function
Control Structures
Sequence control statements
Decision control & conditional statements
Case control statements
Repitition & loop control statements
Some more statements
Array and String
Introduction of Array
Array Declaration
Array Initialization
Two Dimensional Array
Multi Dimensional Array
String
Function and Recursion
Function Definition
Function Declaration
Function Call
Recursion
Pointers
Introduction
Pointer expression
Pointer & functions
Pointer & Array
Multi Dimensional Arrays & Pointer
Arrays of Pointer
Use of Pointer & functions
Structures
Introduction
Giving values to member
Structure Initialization
Comparison of structure variables
Arrays of structures
Arrays within structures
Structures within structures
Passing structure to function
Union
Introduction
Accessing a union member
Initialization of Union variable
Uses of Union
Dynamic Data Structure
Linked list
Stack
Queue
Data File Handling through C
Introduction
File operation
Opening & closing a data file
Creating a data file
Processing a data file
Unformatted data file
C Preprocessor & Macro
Introduction
Macro substitution directives
File inclusion
Compiler control directive
Command line parameter of C
Command line parameter
Header file
Header file
Use of library functions
Some Useful library functions

Union


Introduction

Union are derived data types, the way structure are. Though, unions and structures look alike, and there is a fundamental difference.
 
While structure enables you to create a number of different variables stored in difference places in memory, unions enable you to treat the same space as a number of different variables
 
Union-Definition and Declaration
 
Unions, like structures, contain members whose individual data types may differ from one another.
 
However, the members within a union all share the some storage space within the computer's memory, whereas each member within a structure is assigned its own unique storage area.
 
Thus, unions are used to conserve memory.
 
They are useful for applications involving multiple members, where values need not be assigned to all of the members at any one time.
 
Within a union, the bookkeeping required to store members whose data types are different (having different memory requirements) is handled automatically to the compiler.
 
However, the user must keep track of what type of information is stored at any given time.
 
An attempt to access the wrong type of information will produce meaningless results. In general terms, the composition of a union may be defined as:
 
Union tag
{
Member 1;
Member 2;
…..
member n;
};
 
Where union is required keyword and the other terms have the same meaning as in a structure definition.
 
Individual union variables can then be declared as:
storage-class union tag variable 1, variable 2, . . . , variable n;
 
Where storage-class is an optional storage class specified, union is a required keyword, tag is the name that appears in the union definition, and variable 1, variable 2, . . . , variable n are union.
 
The two declarations may be combined, just as we did with structures. Thus, we can write Storage-class union tag
 
{
Member 1;
Member 2;
. . . . .
member n;
}
 
The tag is optional in this type of declaration.
 
Notice that the union and structure declarations are external to the program functions, but the structure variable is defined locally within each function.