StudyLover
  • Home
  • Study Zone
  • Profiles
  • Contact us
  • Sign in
StudyLover 10. Program to calculate the average of all elements in an array.
Download
  1. C++ Programs list
9. Program to implement matrix multiplication using arrays. : 11. Program to swap private data members of classes named `class1` and `class2` using a friend function.
C++ Programs list

1.      Program to calculate the average of all elements in an array.

  1. #include <iostream.h>

  2. #include<conio.h>

  3. int main() {

  4.     int n, sum = 0;

  5.     float average;

  6.  

  7.     cout << "Enter the number of elements(less then 100): ";

  8.     cin >> n;

  9.  

  10.     int arr[100];

  11.  

  12.     cout << "Enter the elements:\n";

  13.     for (int i = 0; i < n; i++) {

  14.         cin >> arr[i];

  15.         sum += arr[i];

  16.     }

  17.  

  18.     average = (float)sum / n;

  19.  

  20.     cout << "Average of the array elements: " << average << endl;

  21.     getch();

  22.     return 0;

  23. }

9. Program to implement matrix multiplication using arrays. 11. Program to swap private data members of classes named `class1` and `class2` using a friend function.
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website