C program to take marks and show percentage accordingly.

#include <stdio.h>

int main()
{
  int sub[5]; // subject marks
  int i,total = 0 ;
  float p;

  printf("Enter marks for 5 subjects : \n");

  for(i=0;i<5;i++)
  {
    printf("Enter marks for subject [%d] : ",i+1);
    scanf("%d",&sub[i]);
    total = total + sub[i];
  }

  p = (float)total/5;

  printf("Percentage is %0.2f",p);

  return 0;
}
OUTPUT:
Enter marks for 5 subjects :
Enter marks for subject [1] : 45
Enter marks for subject [2] : 85
Enter marks for subject [3] : 67
Enter marks for subject [4] : 72
Enter marks for subject [5] : 55
Percentage is 64.80

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.