| susiede (9) | |
|
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
|
|
| Darkmaster (311) | |
|
post your code and use codetags "<>" for that and what excactly is your problem? | |
|
|
|
| susiede (9) | |
|
I have no code. | |
|
|
|
| Darkmaster (311) | |
|
then get started and ask again if you actually have a problem. i'm not doing your homework | |
|
|
|
| susiede (9) | |
|
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"); } | |
|
|
|
| susiede (9) | |
| i dont know what to do next | |
|
|
|
| Darkmaster (311) | |
|
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. | |
|
|
|
| susiede (9) | |
|
ahhh | |
|
|
|
| susiede (9) | |
| cout<<"THANY YOU"<<; | |
|
|
|