Write a program to accept records of different states using array of structures. The structure should contain char state and number of int engineering colleges, int medical colleges, int
management colleges and int universities. Calculate total colleges and display the state, which is having highest number of colleges.
CODING:#include<stdio.h>
#include<conio.h>
struct sta
{
char name[10];
int e;
int m;
int mng;
int uni;
int t;
};
void main()
{
struct sta s[3];
int i,c;
clrscr();
for(i=0;i<=2;i++)
{
printf("\n%d)State Name:",1);
scanf("%s",s[i].name);
printf("Engneering College:");
scanf("%d",&s[i].e);
printf("Medical College:");
scanf("%d",&s[i].m);
printf("Management College:");
scanf("%d",&s[i].mng);
printf("Universities College:");
scanf("%d",&s[i].uni);
}
printf("-------------------
----",c);
for(i=0;i<=2;i++)
s[i].t=s[i].e+s[i].m+s[i].mng;
if(s[0].t>s[1].t>s[2].t)
printf("\n%s having highset college:%d",s[0].name,s[0].t);
else if(s[1].t>s[2].t)
printf("\n%s having highset college:%d",s[1].name,s[1].t);
else
printf("\n%s having highset college:%d",s[2].name,s[2].t);
getch();
}
Comments
Post a Comment