Array Size Constant

Lab C Beginner 10 points

Use #define MAX_ITEMS 5 to size an array. Read up to MAX_ITEMS prices (the first number says how many, never more than MAX_ITEMS) and print the total with 2 decimals and the capacity left.

Input

n, then n decimal prices.

Output

Two lines.

Example

Input

3
1.5 2.25 10

Output

13.75
2
Sample input available Sample output available
Editor
C

Hints

Changing the #define changes every place that uses it.

Solution explanation

Named size constants keep array sizes and loop limits in sync.

Show solution
#include <stdio.h>
#define MAX_ITEMS 5

int main() {
    double prices[MAX_ITEMS], total = 0;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lf", &prices[i]);
        total += prices[i];
    }
    printf("%.2f\n%d\n", total, MAX_ITEMS - n);
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD