adsense

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

Write a program in C to find the percentage of 5 subject marks,determine the division.

Write a program in C to find the percentage of 5 subject marks,determine the division and determine the student are  pass in all subject or not. If student not pass all subject then count the number of fail subjects.



#include<stdio.h>
#include<conio.h>
 void main()
  {
   int sub[5],i,c=0,c1=0;
   float sum,per;
  clrscr();
   printf("Enter marks of 5 subjects:-");
   for(i=0;i<5;i++)
   scanf("%d",&sub[i]);
   for(i=0;i<5;i++)
    {
    sum=sum+sub[i];
     per=sum/5.0;
     }
     printf("Sum=%.2f\nPercentage=%.2f",sum,per);
   if(per>=60)
     printf("\nFirst division");
    else if(per>=45)
     printf("\nSecond division");
    else if(per>=30)
     printf("\nThird division");
    else
     printf("\nFail");
     
    for(i=0;i<5;i++)
     {
      if(sub[i]<30)
        c++;
      else
        c1++;
      }
     if(c1==5)
        printf("\nPass all subject.");
    else 
        printf("\nFail %d subject.",c);
    getch();
    }

Output:-




Post a Comment

0 Comments