bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

prac_011.cpp (976B)


      1 /*
      2  * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /* average of elements */
      8 
      9 #include <iostream>
     10 using namespace std;
     11 
     12 class avarage {
     13     int inp[100], sum = 0, n, i;
     14     float avg;
     15 
     16 public:
     17     void input();
     18     void calculation();
     19     void output();
     20 };
     21 
     22 void avarage::input() {
     23     cout << "\nEnter the number of elements : ";
     24     cin >> n;
     25     i = 0;
     26     while (i < n) {
     27         cout << "\nEnter the element no " << i + 1 << " : ";
     28         cin >> inp[i];
     29         i++;
     30     }
     31 }
     32 
     33 void avarage::calculation() {
     34     i = 0;
     35     for (i = 0; i < n; i++) {
     36         sum = sum + inp[i];
     37     }
     38     avg = (float)sum / n;
     39 }
     40 
     41 void avarage::output() {
     42     i = 0;
     43     cout << "\nAvarage of the element ";
     44     for (i = 0; i < n; i++) {
     45         cout << "  " << inp[i];
     46     }
     47     cout << "   is : " << avg;
     48 }
     49 
     50 int main() {
     51     avarage z;
     52     z.input();
     53     z.calculation();
     54     z.output();
     55     return 0;
     56 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror