Student Record using Structure - C Program

Program:
    #include<stdio.h>
    int n,i,j;
    struct student
    {
        char name[20];
        int sub1,sub2,sub3,total;
    };
    struct student st[100],temp;
    void readlist()
    {
        for(i=0;i<n;i++)
        {
            printf("\nEnter the name of student:");
                scanf("%s",st[i].name);
            printf("Enter the marks in 3 subjects:");
                scanf("%d%d%d",&st[i].sub1,&st[i].sub2,&st[i].sub3);
            st[i].total=st[i].sub1+st[i].sub2+st[i].sub3;
        }
    }
    void sortlist()
    {
    for(i=0;i<n;i++)
        {
         for(j=0;j<n-i-1;j++)
            {
             if(st[j].total<st[j+1].total)
                {
                 temp=st[j];
                 st[j]=st[j+1];
                 st[j+1]=temp;
                }
            }
        }
    }
    void display()
    {
        for(i=0;i<n;i++)
        {
            printf("\nRank=%d",i+1);
            printf("\nName:%s",st[i].name);
            printf("\nTotal mark=%d\n",st[i].total);
        }
     }
    void main()
    {
        struct student st[100],temp;
        printf("Enter the number of students:");
        scanf("%d",&n);
        readlist();
        sortlist();
        printf("\n\t<<Sorted student Record>>");
        display();
    }

Output
nn@linuxmint ~ $ gcc c15.c
nn@linuxmint ~ $ ./a.out
Enter the number of students:3

Enter the name of student:varun
Enter the marks in 3 subjects:35
30
40

Enter the name of student:athira
Enter the marks in 3 subjects:39
45
40

Enter the name of student:afsal
Enter the marks in 3 subjects:40
45
49

    <<Sorted student Record>>
Rank=1
Name:afsal
Total mark=134

Rank=2
Name:athira
Total mark=124

Rank=3
Name:varun
Total mark=105
nn@linuxmint ~ $

1 comment:

  1. Write a program to maintain student’s record. Record should not be available to any unauthorized user. There are three (3) categories of users. Each user has its own type. It depends upon user’s type that which kind of operations user can perform. Their types and options are mentioned below:

    1. Admin

    (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record)

    2. Super Admin

    (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record, Delete Single Record)

    3. Guest

    (Search Record [by Reg. No or Name], View All Records)



    When first time program runs, it asks to create accounts. Each user type has only 1 account (which means that there can be maximum 3 accounts). In account creation, following options are required:



    Login Name: <6-10 alphabets long, should be unique>

    Password: <6-10 alphabets long, should not display characters when user type>

    Confirm Password:

    Account Type:



    Login Name, Password and Account Type should be stored in a separate file in encrypted form. (Encryption means that actual information should be changed and Decryption means that Encrypted information is changed back to the actual information)



    If any of the above mentioned requirement(s) does not meet then point out mistake and ask user to specify information again.



    When Program is launched with already created accounts, it will ask for user name and password to authenticate. On successful authentication, give options according to the user’s type.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...