#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
Array programs
- Sequence filter in array in C
- Array Search (Linear search)
- Array Merging
- Array Sorting
- C program to take marks and show percentage accordingly.
- C program to take user input to an array and show its content.
- C program to search an element in the array using a user – defined function.
- C program to search an element in the array using bsearch() function.
- C program to sort an array using qsort() functions.
- Recursive binary search in C.
Trending