Write a program to read an unknown number of integer numbers stored in a file
nums.txt and calculate the number of negative, the number of
positive numbers and the
number of zeros. Your application should display on the screen the number of negative
and positive numbers as well as the number of zeros.

What have you tried so far? And please don't say "I don't know how to start", because that's an extremely lame excuse. Anyone with a passing familiarity with C++ should be able to write this as a starting point:

#include <fstream>
#include <iostream>

int main()
{
    ifstream in("myfile.txt");

    if (in)
    {
        int num;

        while (in >> num)
        {
            cout << num << '\n';
        }
    }
}

i tried this

#include <iostream>
#include <fstream>
using namespace std;

int nums[5];
int main()

    ofstream myfile; // input file
// array to hold numbers
myfile.open("nums.txt");
myfile << "1 0 0 -1 2";
myfile.close();
system("pause");
return 0;

}{

ofstream myfile; // input file

In what way does ofstream represent an input file? Take a look at my basic starting point example and work from there. You're reading a file, not writing one.

Thank you,
after you read the numbers from the file, it will do the test for measurement, amounts have positive
and how negative

Right now all it does is print out the numbers. I'm not going to write the whole thing for you, so try to finish up that last part. I assure you, it's quite simple. I'll even give you a hint: use three counter variables and increment them appropriately for each number, then print those counters after the loop ends.

I understand that it will not write the whole program for me, and thank you for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.