Friday, October 30, 2009

Chap10[D]a Printing specfic datas in structures

Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the collage. (a) Write a function to print names of all students who joined in a particular year. (b) Write a function to print the data of a student whose roll number is given.


void main()
{
char j[1];
int yearc,rollc,i;

struct book
{
int roll;
char name[20];
char department[20];
char course[20];
int year;

};

struct book b[5]={
{1,"MrA","Science","Physics",2009},
{2,"MrB","Science","Maths",2008},
{3,"MrC","Arts","History",2009},
{4,"MrsD","Arts","History",2010},
{5,"MrsE","Science","Maths",2009}
};

while(1)
{
clrscr();
printf("\nEnter a year(2000 or 2001)\n");
scanf("%d",&yearc);
for(i=0;i<5;i++)
{
if(yearc==b[i].year)
printf("\nName: %s Year: %d",b[i].name,b[i].year);
}

printf("\nEnter a roll number(1-5)\n");
scanf("%d",&rollc);

for(i=0;i<5;i++)
{
if(rollc==b[i].roll)
{
printf("\nRoll number: %d, Name: %s, Department: %s\nCourse: %s,Year: %d",b[i].roll,b[i].name,b[i].department,b[i].course,b[i].year);
break;
}
}

printf("\nPress q to quit or any key to continue\n");

scanf("%s",j);
if(j[0]==113)
break;
}

}

linkfloat()
{
float a=0,*b;
b=&a;
a=*b;
}

No comments:

Post a Comment