Search This Blog

Wednesday 13 January 2016

Structure of students marks

#include<stdio.h>
#include<conio.h>
struct student
{
    int roll;
    char name[100];
    int sub[3],tot,perc;
};
void main()
{
    struct student a[5];
    int i,j,n;
    clrscr();
    printf("Enter no of student");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("Enter roll no");
        scanf("%d",&a[i].roll);
        printf("Enter the name of student");
        flushall();
        gets(a[i].name);
        for(j=0;j<3;j++)
        {
            printf("Enter the marks of subject =%d",j+1);
            scanf("%d",&a[i].sub[j]);
            a[i].tot=a[i].tot+a[i].sub[j];
        }
        a[i].perc=a[i].tot/3;
        for(j=0;j<=n;j++)
        {
            if(a[i].perc>65)
            {
                printf("\nroll num =%d", a[i].roll);
                printf("\nname");
                flushall();
                puts(a[i].name);

                for(j=0;j<3;j++)
                {
                    printf("\nsub %d = %d",j+1,a[i].sub[j]);
                }
                printf("\ntotal marks =%d",a[i].tot);
                printf("\npercentage %d",a[i].perc);
            }
        }
    }
    getch();
}

No comments:

Post a Comment