Example to Illustrate Union

Description

Illustrate how members of union are sharing same memory.

Solution

union area
{
   int x, y;
};
 
int main()
{
    union area a;
 
    a.x = 2; 
    printf ("After making x = 2:\n x = %d, y = %d\n\n",
             a.x, a.y);
 
    t.y = 10;  
    printf ("After making Y = 10:\n x = %d, y = %d\n\n",
             a.x, a.y);
    return 0;
}

Explanation

because both x any shares same memory changes in on variable affects the another.



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution

Related Programs