1 solutions

  • 0
    @ 2025-11-5 19:22:30

    C++ :

    #include<iostream>
    #include<string>
    #include<iomanip>
    #include<cmath>
    
    using namespace std;
    
    float RunningAvg(float);
    
    int main()
    {
    	int x = 1;
    	float avg;
    	int n;
    
    	cin>>n;
    
    	while (x < 20)
    	{
    		avg = RunningAvg(x);
    		cout<<"Average is: "<<avg<<endl;
    		x= x +3;
    	}
    }
    
    float RunningAvg(float a)
    {
    	static float total = 0.0;
    	static int count = 0;
    	total = total + a;
    	count++;
    	return total/float(count);
    }
    
    • 1

    Information

    ID
    19306
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By