adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C to enter student marks and find the sum, percentage and result (pass /fail)

Program in C to enter student marks and find sum, percentage and result (Pass /Fail)


#include<stdio.h>
#include<conio.h>
  struct student
   {
       char name[20];
       int roll;
       float avg;
       char pass;
       int a,b,c,d,e,sum;
   };
   int main()
    {
        int n,i,j;
        struct student s1[20];
        printf("How many student details add:-");
        scanf("%d",&n);
        for(i=0;i<n;i++)
         {
          system("cls");
            fflush(stdin);
            printf("Enter student name:-");
            gets(s1[i].name);
            printf("roll no.");
            scanf("%d",&s1[i].roll);
            printf("Enter five subject marks:-");
            scanf("%d%d%d%d%d",&s1[i].a,&s1[i].b,&s1[i].c,&s1[i].d,&s1[i].e);
            s1[i].sum=s1[i].a+s1[i].b+s1[i].c+s1[i].d+s1[i].e;
            s1[i].avg=s1[i].sum/5;
            if(s1[i].a>=30&&s1[i].b>=30&&s1[i].c>=30&&s1[i].d>=30&&s1[i].e>=30)
                s1[i].pass='P';
            else
                s1[i].pass='F';
                getch();
        }
        system("cls");
        printf("\t----Entered Student Marks Details----\n");
        printf("----------|------------|--------|-------|------|-------|-------|--------|-------|-------");
        printf("\n  Name\t\tRoll no.   sub1    sub2   sub3   sub4   sub5     sum       avg     pass\n");
        printf("----------|------------|--------|-------|------|-------|-------|--------|-------|-------\n");
    for(i=0;i<n;i++)
        {
            printf("  %s",s1[i].name);
            printf("%8d",s1[i].roll);
      printf("\t%7d%7d%7d%7d%7d",s1[i].a,s1[i].b,s1[i].c,s1[i].d,s1[i].e);
            printf("\t%d",s1[i].sum);
            printf("\t  %.2f",s1[i].avg);
            printf("%8c",s1[i].pass);
            printf("\n");
        }
   getch();
}
Output:-









Post a Comment

0 Comments