A struct in C programming language is a structured (record) type that aggregates a fixed set of labelled objects, possibly of different types, into a single object.
A
struct
declaration consists of a list of fields, each of which can have any type. The total storage required for a struct object is the sum of the storage requirements of all the fields, plus any internal padding./* Objective: To prepere a menu which offer following facilities:
-Register a student
-delete record
-search record and print its average
-display list of student as per percentage obtained */
// Source Code //
#include<stdio.h> //including header files//
#include<string.h>
#include<conio.h>
struct info
//declaration of structure//
{
char name[20];
char branch[20];
int year;
int marks[5];
float percent;
char eno[20];
}student[50];
//Function Declaration//
void enter(int);void del(int);
void search(int);
void display(int);
int main()
{
int i,n;
char choice;
printf("enter the no of students u want to register\t");
scanf("%d",&n); // taking no of records to enter//
enter(n); // calling enter function//
do
{
printf("enter\n 1:Delete \n 2:search \n 3:Display");
scanf("%d",&i); //taking user's choice//
switch(i)
{
case 1:
del(n); // calling del function//
break;
case 2:
search(n); // calling search function//
break;
case 3:
display(n); // calling display function//
break;
default:
printf("invalid choice");
break;
}
printf("do u wanna continue press y or n");
scanf("%c",&choice);
}
while(choice=='y' || choice =='Y');
getch();
}
void enter(int n) // function definition//
{
int i,j;
for(i=0;i<n;i++)
{
printf("Enter name,branch,year,enrolement no. of student");
scanf("%s %s %d %s",student[i].name,student[i]
//taking student info//
printf("enter marks of 5 subject");
for(j=0;j<5;j++)
scanf("%d",&student[i].marks[
}
}
void del(int n) // function definition//
{
char sname[20];
int i,j,flag;
printf("enter the name of student whose records u wanna delete:");
scanf("%s",sname);
for(i=0;i<n;i++)
if(strcmp(student[i].name,
flag=i;
for(j=flag;j<n-1;j++)
{
strcpy(student[j].name,
student[j].year=student[j+1].
strcpy(student[j].branch,
for(i=0;i<5;i++)
student[j].marks[i]=student[j+
strcpy(student[j].eno,student[
}
printf("The records after deleting info are:");
display(n-1); //function call for display function//
}
void search(int n) //function definition//
{
int i, avg,j, flag;
char eno[20];
printf("enter eno of student whose marks are to be calculated");
scanf("%s",eno);
for(i=0;i<n;i++)
if(strcmp(student[i].eno,eno)=
flag=i;
for(j=0;j<n;j++)
printf("\nThe avg is %d",avg);
}
void display(int n) // function definition//
{
int i,j,sum[50],pos,a[50],k;
float small;
struct info s1;
for(i=0;i<n;i++)
{
sum[i]=0;
for(j=0;j<5;j++)
sum[i]+=student[i].marks[j];
student[i].percent=(float)sum[
}
printf("The information of students are:");
for(i=0;i<n;i++)
{
// sorting info in increasing order of percentage//
for(j=0;j<n-i-1;j++)
{
if(student[j].percent>student[
{
strcpy(s1.name,student[i].
strcpy(s1.branch,student[i].
strcpy(s1.eno,student[i].eno);
s1.year=student[i].year;
for(k=0;k<5;k++)
s1.marks[k]=student[i].marks[
s1.percent=student[i].percent;
strcpy(student[i].name,
strcpy(student[i].branch,
strcpy(student[i].eno,student[
student[i].year=student[i+1].
for(k=0;k<5;k++)
student[i].marks[k]=student[i+
student[i].percent=student[i+
strcpy(student[i+1].name,s1.
strcpy(student[i+1].branch,s1.
strcpy(student[i+1].eno,s1.
student[i+1].year=s1.year;
for(k=0;k<5;k++)
student[i+1].marks[k]=s1.
student[i+1].percent=s1.
}
}
}
for(i=0;i<n;i++)
{
printf("\nName: %s \n branch: %s \n enrolement no: %s",student[i].name,student[i]
printf("\nThe marks of 5 subjects are:");
for(j=0;j<5;j++)
printf("\n%d",student[i].
printf("\npercentage %f",student[i].percent);
}
}
u r a genious .. tz code doesn't shows dat u hav little interest in pgming,,instead it shows ur an expert programmer......
ReplyDeleteThnxx for appraisals..... :) :)
Deletethankz a lot for providing such useful codings....
ReplyDeleteHey there just wanted to give you a quick heads up and let
ReplyDeleteyou know a few of the pictures aren't loading properly. I'm not sure why but I think its
a linking issue. I've tried it in two different internet browsers and both show the same results.
Feel free to visit my web site :: ipad2 cyber Monday 2012