'Compare vector to an input number and count numbers in vector that is greater

//How do I count numbers in the input vector that is greater and lesser than input number X?

#include <iostream>

#include #include

using namespace std;

int main() {

int i, size;
float verdi = 0;
vector<float> minvektor;

cout << "input vectorsize " << endl;
cin >> size;
cout << "Input vector-numbers, use enten space or enter to space/divide numbers. " << endl;

for (i = 0; i < size; i++)
{
    cin >> verdi;
    minvektor.push_back(verdi);
}

for (i = 0; i < size; i++)
{
    cout << minvektor[i] << " ";
}
// -------------------------------------------------
cout << "\ninput number X to compare to vector: " << endl;

float X;
cin >> X;

//count numbers in a vector that is greater than X

//output ex: 5 numbers in a vector that is greater than number X

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source