static

 //static store last value

#include<iostream.h>


float avg(int );

int main(int argc, char *argv[])

{

int n;

float res;

for(;;){

cout<<"Enter a num;";

cin>>n;

res=avg(n);

cout<<res<<endl;


}

return  0

}

float avg(int x)

{

static int c=0;

static float total=0;

c++;

total+=x;

return(total/c);

}

Comments

Popular posts from this blog

serial to parallel test with 74c595 and pic mcu

ဆိုလာ စနစ္ရွိ BATTERY AMPACITY အား design ထုတ္တြက္ခ်က္ၿခင္း (1) watt hour ရယူၿခင္း

INTERRUPT_ON_CHANGE_18f4550