Search This Blog

Thursday, 31 October 2024

6. Write a C program to read marks scored in 3 subjects by n students and find the average of marks and result (Demonstration of single dimensional array)

 /* 6. Write a C program to read marks scored in 3 subjects by n students and find the average of marks and result (Demonstration of single dimensional array) */

#include<stdio.h>

void main()

{

     int sub1[10],sub2[10],sub3[10],total[10],avg[10],n,i;

     printf("Enter no of students:");

     scanf("%d",&n);

     for(i=0;i<n;i++)

     {

           printf("Enter the marks of Student-%d:\n",i+1);

           scanf("%d",&sub1[i]);

           scanf("%d",&sub2[i]);

           scanf("%d",&sub3[i]);

           total[i]=sub1[i]+sub2[i]+sub3[i];

           avg[i]=total[i]/n;

     }

     printf("Results are as follows:\n");

     for(i=0;i<n;i++)

     {

           printf("Student-%d is as follows:\n",i+1);

           if((total[i]*100/300)>=70)

                printf("Distinction\n");

           else if((total[i]*100/300)>=60)

                printf("First Class\n");

           else if((total[i]*100/300)>=50)

                printf("Second Class\n");

           else if((total[i]*100/300)>=40)


                printf("Pass\n");

           else

                printf("Fail\n");

     }

     getch();

}

No comments :

Post a Comment

FREE Hit Counters