Student Structure coderinme

Student Structure coderinme

Student Structure coderinme
Let us now create a structure which will specify data on students given below: Roll No, Name Department, Course, Year of passing Assume that are not more than 450 students in collage. (i). Write a function to print names of all students who joined in a particular year. (ii). Write a function to print the data of a student whose roll number is given.

#include<stdio.h>
struct student
{
int roll;
char name[20];
char department[20], course[20];
int year;
} pe[450]={{1,"John Doe","computer","mca",2008},{2,"John Doe2","civil","btech",2009},{3,"John Doe3","chemical","btech",2010},{4,"John Doe4","electrical","btech",2011},{5,"John Doe5","electronics","btech",2012},{6,"John Doe6","mechanical","btech",2013},{7,"John Doe7","petrochemical","btech",2014},{8,"John Doe8","computer","bca",2015}};
void name()
{
int yr,i;
printf("Please give the year\n");
scanf("%d",&yr);
for(i=0;i<sizeof(pe[0]);i++)
{
if(yr==pe[i].year)
{
printf("Roll Number:%d\nName:%s\nDepartment:%s\nCourse:%s\nYear of passing:%d\n",pe[i].roll,pe[i].name,pe[i].department,pe[i].course,pe[i].year);
}
}
}
void roll_number()
{
int roll_no,i;
printf("\nPlease give the roll number:\n");
scanf("%d",&roll_no);
for(i=0;i<sizeof(pe[0]);i++)
{
if(roll_no==pe[i].roll)
{
printf("\nRoll Number:%d\nName:%s\nDepartment:%sCourse:%s\nYear of passing:%d\n",pe[i].roll,pe[i].name,pe[i].department,pe[i].course,pe[i].year);
}
}
}
int main()
{
name();
roll_number();
getch();
return 0;
}

For more programs in C, visit our C Coder Archives

Student Structure coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.