Write a c program to create student structure having field roll_no, stud_name, mark1, mark2, mark3 calculate the total and average of marks and arrange the records in descending order of marks

#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
int rollno;
char name[20];
int m1,m2,m3;
float percent;
};
struct student s[20],t;
int i,j,n;
clrscr();
printf("\n enter the limit");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n enter the roll no\n");
scanf("%d",&s[i].rollno);
printf("\n enter the name \n");
scanf("%s",s[i].name);
printf("\n enter the mark=");
scanf("%d",&s[i].m1);
printf("\n enter the mark=");
scanf("%d",&s[i].m2);
printf("\n enter the mark=");
scanf("%d",&s[i].m3);
s[i].percent=(s[i].m1+s[i].m2+s[i].m3)/3;
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(s[i].percent<s[j].percent)
{
t=s[i];
s[i]=s[j];
s[j]=t;
}
}
}
printf("\n display in desending order\n");
for(i=0;i<n;i++)
{
printf("\n rollno=%d",s[i].rollno);
printf("\n name=%s",s[i].name);
printf("\n mark1=%d",s[i].m1);
printf("\n mark2=%d",s[i].m2);
printf("\n mark3=%d",s[i].m3);
printf("\n percent=%f",s[i].percent);
}
getch();
}

12 comments:

  1. hi sir.my question isWrite a c program to create student structure having field roll_no, stud_name, mark1, mark2, mark3 calculate the total and average,result of marks and arrange the records in descending order of marks in files concept in c language.

    ReplyDelete
  2. sir plz i dont understand files concept i even write on this program
    #include
    #include
    void main()
    {
    FILE *fp;

    char name[1000][20],na[1000][20];
    int a[1000][5],b[1000][5];
    int i,j,n,flag=0,total=0;
    char grade[10]="---";
    char result[10]="pass";
    float avg=0.0;
    int roll[100],r[100];
    clrscr();
    fp=fopen("s.txt","w");
    if(fp==NULL)
    printf("error ");
    else
    {
    printf("\nhow many students data you have to enter ");
    scanf("%d",&n);

    for(i=0;i100 || a[i][j]<0)
    {
    printf("\nmarks should be between 0 to 100 only re enter it");
    printf("enter %d subject marks ",i+1);
    scanf("%d",&a[i][j]);
    }
    }
    fprintf(fp,"%d %s %d %d %d %d %d %d",roll[i],name[i],a[i][0],a[i][1],a[i][2],a[i][3],a[i][4],a[i][5]);
    fprintf(fp,"%c",'\n');
    }
    clrscr();
    fclose(fp);
    fp=fopen("s.txt","r");

    printf("\nno name s1 s2 s3 s4 s5 s6 tot avg res grd");
    printf("\n-----------------------------------------------------------");
    for(i=0;i=60.00 && avg<=100.00)
    strcpy(grade,"first");
    if(avg>=50.00 && avg<=59.99)
    strcpy(grade,"second");
    if(avg>=35.00 && avg<=49.99)
    strcpy(grade,"third");
    }
    fprintf(stdout,"%d %s %d %d %d %d %d %d %d %.2f %s %s",r[i],na[i],b[i][0],b[i][1],b[i][2],b[i][3],b[i][4],b[i][5],total,avg,result,grade);
    }
    }
    getch();
    }
    is this program is correct or not.any mistakes plz correct sir.send me reply plz

    ReplyDelete
  3. i want algorithm and flow chart for this question pls help me


    create a structure(roll no,name'marks in three subject,percentage).accept details of n students and write a menu driven programs the following differnt options.
    1-search
    2-modify
    3-display all student details
    4- display all student having percentage>_
    5-display all student having maximum percentage

    ReplyDelete
  4. Sir. my question is WAP to process student structure containing roll number, class and age as members. The program must read 5 student record in an array of structure and display the details of a student who is eldest. Use a function to find the eldest for which array of structure is an argument in c language.

    ReplyDelete
  5. Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING

    ReplyDelete
  6. take a structure that stores details of student 3 functions one input one for output one calculating average and percentage

    ReplyDelete
  7. {plz solve this problem}*******************
    suppose you are asked to make a final mark sheet of 2 students. now write a program that will calculate the total marks for the indivitual student and display the marks sheet exactly in a following manner.(suppose mid1 ,mid2 are taken out of a score of 100. but you need to take only 50% on them).

    student name quiz(20%) mid1(40%) mid2(40%) total(100%)
    atif 20 40 20 80

    ReplyDelete
  8. Write a program that uses structure data type variable to store student name and ID.
    The program takes the input from user and display it.
    Make separate functions to take Input and output.
    Pass structure as function argument to input method and as well as return type in output method.

    ReplyDelete
  9. a student structure consisting of data member Rollno (integer),
    Stu_name (pointer to char) and marks (array of 3 integers). Give
    declaration for structure variable

    ReplyDelete
  10. write a program in c to display details of 100 students(marks,roll no,name) and average of their marks

    ReplyDelete