Hacker Rank: Plus Minus

Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with places after the decimal.

void plusMinus(int arr_count, int* arr) {
    int neg_num=0, pos_num=0, zero_num=0;
    for (int i=0; i<arr_count; i++){
        if(arr[i]>0) pos_num++;
        else if(arr[i]<0) neg_num++;
        else zero_num++;


Leave a Comment