19.Example of Array

 #include <stdio.h>


int main()
{
    int sum = 0; float percentage;
    int a[5];
    for (int i = 0; i < 5; i++)
    {
        printf("\nEnter the marks of subject %d:", i + 1);
        scanf("%d", &a[i]);
    }
    for (int j = 0; j < 5; j++)
    {

        printf("The marks of subject %d is:%d\n", j + 1, a[j]);
        sum = sum + a[j];
    }
    printf("\nTotal marks=%d", sum);
    percentage = (float)(sum*100)/500;
    printf("\nPercentage=%0.2f%%",percentage);//%% is used to print %
    return 0;
}

Comments