/* Write a function double random_ave(int size) that has one integer parameter, size. The function generates size integers between 0 and 50. The function returns the average of even numbers between 11 and 33. If there are no such numbers, the function returns -1. Write main that test the function on random size */ #include #include #include double random_ave(int); int main(){ srand(time(NULL)); int size = rand()%11; printf("size is %d\n",size); double res; if(size>0){ res=random_ave(size); if(res==-1) printf("no evens between 11 and 33\n"); else printf("ave=%f\n",res); } else printf("invalid input\n"); return 0; } double random_ave(int size){ int i, num, sum=0, count=0; for(i=0;i=11 && num<=33){ sum+=num; count++; } } printf("\n"); if(count>0) return (double)(sum)/count; else return -1.0; }