Simple Array example In C

Arrays are structures that hold multiple variables of the same data type. An array from integer type holds The array subject contains an array of 10 integer values. We can use each member of array by specifying its index value. Members of above array are subject[0],...,subject[9] and we can work with these variables like other variables: Receive 5 subject of a student in an array and finally calculate his average.

How to print a 5 subject marks and avarage

#include<stdio.h> int main() { int subject[5],sum; float avg; printf("Enter english :"); scanf("%d",&subject[0]); printf("Enter maths :"); scanf("%d",&subject[1]); printf("Enter science :"); scanf("%d",&subject[2]); printf("Enter sst :"); scanf("%d",&subject[3]); printf("Enter urdu :"); scanf("%d",&subject[4]); sum=subject[0]+subject[1]+subject[2]+subject[3]+subject[4]; avg=sum/3; printf("Sum is = %d\nAverage = %f\n",sum,avg); }