TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Friday 29 May 2020

Unions In C++ | Unions In C++ Programming Language | Unions In C++ Language In Hindi

Unions In  C++


Union is a user-defined datatype. All the members of union share same memory location. Size of union is decided by the size of largest member of union. If you want to use same memory location for two or more members, union is the best for that.Keyword is “union” is use in union when we make program of union.

 

image of Unions In  C++

Fig: Unions In  C++

Syntax:

union union name

{

union  memeber1;

union memeber2;

union memeber3;

};<union variable>;

 

Example:

union MCA

{

int age;

char name[20];

}p;

 

Program:

#include<iostream.h>

#include<conio.h>

union MCA

{

char name [30];

char place[50];

int pincode;

}p;

void main()

{

cout<<”input name”;

cin>>p.name;

cout<<”input place”;

cin>>p.place;

cout<<”input pincode”;

cin>>p.pincode;

cout<<p.name;

cout<<p.place;

cout<<p.pincode;

getch();

}

 
Output:

Input name    Pramod

Input place    Delhi

Input pinocde  201301

Pramod

Delhi

 201301

 

 

 


No comments:

Post a Comment