1. Program to calculate the average of all elements in an array.
#include <iostream.h>
#include<conio.h>
int main() {
int n, sum = 0;
float average;
cout << "Enter the number of elements(less then 100): ";
cin >> n;
int arr[100];
cout << "Enter the elements:\n";
for (int i = 0; i < n; i++) {
cin >> arr[i];
sum += arr[i];
}
average = (float)sum / n;
cout << "Average of the array elements: " << average << endl;
getch();
return 0;
}