Write
a program that generates a list of students. Use structure variables to store
the names ,roll-no, class and city of each student. The program should also
display the number of students coming from a particular city (say:’Chiplun’).
source file name: StudentList.C
#include<string.h>struct student
{
int rollno;
char name[15];
char studclass[10];
char city[10];
};
void main()
{
int i,n,cnt=0;
char ct[10];
struct student s[]={
{201,"Sachin Patil","FYCS","Chiplun"},{202,"Shetal Pawar","SYCS","Chiplun"},
{203,"Mohan Joshi","TYCS","Ratnagiri"},{711,"Soham Kadam","FYCS","Mumbai"},
{331,"Harish Mane","SYIT","Poona"}};
clrscr();
printf("\n Student list: ");
for(i=0;i<5;i++)
{
printf("\n %d\t%s\t%s\t%s ",s[i].rollno,s[i].name,s[i].studclass,s[i].city);
}
printf("\n select city name from Chiplun , Ratnagiri,Mumbai or Poona: \n");
gets(ct);
for(i=0;i<5;i++)
{
n=strcmpi(ct,s[i].city);
if(n==0)
cnt++;
}
printf("\n student coming from %s are %d ",ct,cnt);
getch();
}
output:
0 Comments
Post a Comment