Hackerrank solution Plus Minus - Solution in C | Algorithm - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Saturday, May 6, 2017

Hackerrank solution Plus Minus - Solution in C | Algorithm

Hackerrank solution Plus Minus - Solution in C | Algorithm


HackerRank Online Judge Solution Plus Minus  | Data structures
HackerRank Main Problem Link - https://www.hackerrank.com/challenges/plus-minus

Problem Name: HackerRank Problem  Plus Minus
Problem Number : HackerRank Problem Plus Minus Solution


Online Judge : HackerRank Online Judge Solution
Category: Algorithm
Solution Language : C, C plus plus

Hackerrank solution Plus Minus - Solution in C | Algorithm


HackerRank Solution Plus Minus Code in C:


#include<stdio.h>
int main()
{
    int n, i, positives = 0, negatives = 0, zeros = 0;
    float answernegative = 0.0, answerPositive = 0.0, answerZero = 0.0;
    int number;

    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
       scanf("%d", &number);
       if(number > 0)
            positives += 1;

        else if(number < 0)
            negatives += 1;

       else
           zeros += 1;

    }


    answerPositive = (float)positives/n;
    answernegative = (float)negatives/n;
    answerZero = (float)zeros/n;

    printf("%.6f\n%.6f\n%.6f\n", answerPositive, answernegative, answerZero);

    return 0;
}

2 comments:

  1. +
    --
    +++
    ----

    How to slove this pattern in c program?

    ReplyDelete
  2. +
    --
    +++
    ----

    How to slove this pattern in c program?

    ReplyDelete