Difine a struct with tag population with fields Men & women.Create structure with in structure using state and population structure. Read and display the data.
CODING:#include<stdio.h>
#include<conio.h>
void main()
{
struct{
char name[20];
float total;
struct{
int men,women;
}pop;
}state;
clrscr();
printf("\nEnter state name : ");
flushall(); gets(state.name);
printf("Total population : ");
flushall(); scanf("%f",&state.total);
printf("Population - Men (%) : ");
flushall(); scanf("%d",&state.pop.men);
printf("Population - Women (%) : ");
flushall(); scanf("%d",&state.pop.women);
clrscr();
printf("\nState\t\t - %s",state.name);
printf("\nPopulation\t - %6.2f",state.total);
printf("\nMen\t\t - %d%",state.pop.men);
printf("\nWomen\t\t - %d%",state.pop.women);
getch();
}
void force()
{
float x,*y;
y=&x;
x=*y;
}
Comments
Post a Comment