about array

closed account (4y79216C)
hello everyone can someone help me about array plsss i really need help right now

using one-dimensional array. create a program that will count the number of the same intries in a series number based on the user specific no. to count
EXPECTED output
Enter no.1:2
Enter no.2:1
Enter no.3:1
Enter no4:2
what number to v=count?1
total number 1 is 2

should use a counter
i appretiate those who will answer
closed account (4y79216C)
this is my code
#include<iostream>
using namespace std;
int main()
{
int n,hn,nc;
int i;
int count;
float totaln;
count=0;

cout<<"ENTER MANY NUMBERS TO INPUT?:"<<endl;
cin>>hn;

for(i=1;i<=hn;i++)
{

cout<<"ENTER NUMBER :"<<i<<":";
cin>>n;}



cout<<"WHAT NUMBER TO COUNT:"<<endl;
cin>>nc ;
count=0;
totaln+=n;

cout<<"THE TOTAL NUMBER IS:"<<totaln;


system("PAUSE");
}
I'm trying to understand what you're doing. maybe this will help?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
int _tmain(int argc, _TCHAR* argv[])
{
	
int hn,nc;
int i;
int count;
float totaln;
count=0;

cout<<"ENTER MANY NUMBERS TO INPUT?:"<<endl;
cin>>hn;
int* n = new int[hn];
for(i=1;i<=hn;i++)
	{
		cout<<"ENTER NUMBER :"<<i<<":";
		cin>>n[i];
	}
	cout<<"WHAT NUMBER TO COUNT:"<<endl;
		cin>>nc ;
		
		cout<<"THE TOTAL NUMBER IS:"<<nc;
		system("PAUSE");

return 0;
}
closed account (4y79216C)

the counter was not include but thanks for the codes
but when i enter it like this for example
ENTER MANY NUMBERS TO INPUT:2
ENTER NUMBER1:5
ENTER NUMBER2:6
WHAT NUMBER TO COUNT:1
instead of 0,
it became the total number is 1
hmmmm i wonder why??
Now can you explain your program step-by-step? (especially WHAT NUMBER TO COUNT)
Up to now you haven't given us all necessary information yet...
And, we have no idea what your program should be.
closed account (4y79216C)
Enter how many numbers?: 4
Enter no.1: 2
Enter no.2: 1
Enter no.3: 1
Enter no4: 2
what number to v=count?:1 // u will enter
total number 1 is: 2 // the number 1 is been add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#include<iostream>
using namespace std;
int main()
{
int n,hn,nc;
int i;
int count;
float totaln;
count=0;

cout<<"ENTER MANY NUMBERS TO INPUT?:"<<endl;
cin>>hn;

for(i=1;i<=hn;i++)
{

cout<<"ENTER NUMBER :"<<i<<":";
cin>>n;}



cout<<"WHAT NUMBER TO COUNT:"<<endl;
cin>>nc ;
count=0;
totaln+=n;

cout<<"THE TOTAL NUMBER IS:"<<totaln;


system("PAUSE");
}




closed account (4y79216C)
near to finish
Topic archived. No new replies allowed.