السابق التالي
0 / 21
الوحدة النمطية DEMO-32-106DEMO-C-32

Calculate Average

DEMO-C-32 • Programming in C

Browser-only practice

بيان المشكلة

Write a C program to calculate the average of elements in a 1D array. Input the size n, read n integers, calculate the sum, and then divide by n to find the average. Display the average formatted to 2 decimal places.

Example

Input:

5 10 20 30 40 50

Output:

30.00

قيود

1 <= n <= 100

تنسيق الإدخال

n and n integers

تنسيق الإخراج

Float with 2 decimal places

حالات اختبار نموذجية

Submit runs every public testcase in this browser. Results and code never leave this device.

العينة رقم 1
عينة ظاهرة
5
1 2 3 4 5
3.00
Sum=15, 15/5 = 3.00
العينة رقم 2
عينة ظاهرة
4
1 1 1 2
1.25
Sum=5, 5/4 = 1.25
العينة رقم 3
عينة ظاهرة
3
-5 -5 -5
-5.00
Sum=-15, -15/3 = -5.00

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
إعدادات المحرر