help with int sum, average and total number

I just need help finding the count of the numbers that the user has entered, I don't need the sum or the total




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
using namespace std;
int main()
{
    float n = 1,sum=0.0,countz=0.0,average;
    int i=0;

    while(n!=0)
    {
        cout<<"Enter number"<<(i+1)<<" :";
        cin>>n;
        if(n<=0)
            break;
        sum+=n;
        countz+n;
        i++;

    }

Last edited on
it appears to be 'i'
line 15 does not do anything, and its not clear what it should do.
but change line 20 to print i and you have it.
Last edited on
Thanks jonin!!!, wow I forgot that
Topic archived. No new replies allowed.