{ A destination to learn coding }

To calculate sum of subjects and find percentage


#include < stdio.h >
int main()
{
    int n,b,i,total;

    printf("Enter the number of subjects \n");
    scanf("%d",&n);

    float marks[n],percentage,sum=0;

    printf("Enter the maximum marks for one subject \n");
    scanf("%d",&b);

    total=b*n;

    printf("Enter the marks\n");

    for(i=0;i<n;i++)
    {
        scanf("%f",&marks[i]);
        sum+=marks[i];

    }
    printf("The sum is %f\n",sum);
	
  //formula for calculating percentage
    percentage=(100*sum)/total;

    printf("The percentage is %f",percentage);
    return 0;


}