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

pleasss help me
Last edited on
post your code and use codetags "<>" for that
and what excactly is your problem?
closed account (4y79216C)
I have no code.
then get started and ask again if you actually have a problem.
i'm not doing your homework
closed account (4y79216C)
joke lng nara


#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)
i dont know what to do next
since you want to use arrays, you need to set up an array

like this:
datatype Name[size];
example: int MyArray[5]

next save the users input in the array.
you use its elements like this MyArray[0] to MyArray[size-1]

then use a loop to run through all elements of the array and use if to compare them with the number you want to count. if the if statement is treu increase your counting number.
closed account (4y79216C)
ahhh
closed account (4y79216C)
cout<<"THANY YOU"<<;
Topic archived. No new replies allowed.