Create a union containing 6 strings: name, home_address, hostel_address, city, state and zip. Write a C program to display your present address.

Program Code:
#include<stdio.h>
#include<string.h>
union details
{
char name[20];
char home_add[30];
char hostel_add[30];
char city[10];
char state[10];
int pincode;
}a;
void main()
{
strcpy(a.name,"rama");
printf("\n %s",a.name);
strcpy(a.home_add,"1-83/10,jublie hills");
printf("\n %s",a.home_add);
strcpy(a.hostel_add,"iare college");
printf("\n %s",a.hostel_add);
strcpy(a.city,"hyderabad");
printf("\n %s",a.city);
strcpy(a.state,"telangana");
printf("\n %s",a.state);
a.pincode=500043;
printf("\n %d",a.pincode);
getch();
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

2 comments: