Decode School

Decode School - The School for Problem Solvers
Welcome to My Blog.
Need Assignment / Project Guidance (or) Training in Python?

Example to Illustrate Union

Illustrate how members of union are sharing same memory.

Program or 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;
}

					    
					

Program Explanation

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