We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
voidplusMinus(intarr_count,int*arr){// create variables for neg, pos, and zerofloatneg=0;floatpos=0;floatzero=0;// create a for loop to parse the arrayfor(inti=0;i<arr_count;i++){//check if the integer is neg, pos, or 0if(arr[i]>0){//+= into each variable depending on [i]pos+=1;}elseif(arr[i]<0){neg+=1;}else{zero+=1;}}floatposAns=pos/arr_count;floatnegAns=neg/arr_count;floatzeroAns=zero/arr_count;printf("%.6f\n",posAns);printf("%.6f\n",negAns);printf("%.6f\n",zeroAns);
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
In C `