Write a program to get the details of 'n' colleges and to display their details.
Create a structure called College.
struct College
{
char name[100];
char city[100];
int establishmentYear;
float passPercentage;
};


Implementation of the above problem:

#include<stdio.h>
int main()
{
struct College
{
char name[100];
char city[100];
int establishmentYear;
float passPercentage;
};
int n,i,j;
printf("Enter the number of colleges\n");
scanf("%d",&n);
struct College stud[n];
j=1;
for(i=0;i<n;i++)
{    
printf("Enter the details of college %d\n",j);
printf("Enter name\n");
scanf("%s",stud[i].name);
printf("Enter city\n");
scanf("%s",stud[i].city);
printf("Enter year of establishment\n");
scanf("%d",&stud[i].establishmentYear);
printf("Enter pass percentage\n");
scanf("%f",&stud[i].passPercentage);
j++; 
}
j=1;

printf("Details of colleges\n");
for(i=0;i<n;i++)
{   
printf("College %d\n",j);
printf("Name : %s\n",stud[i].name);
printf("City: %s\n",stud[i].city);
printf("Year of establishment : %d\n",stud[i].establishmentYear);
printf("Pass percentage: %.2f\n",stud[i].passPercentage);
j++;
}

return 0;
}



Thanks
Mukesh Rajput
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:

0 comments: