# In dire need of some help

• 04-12-2011
nickd1085
In dire need of some help
Hey guys,

First of all, love the boards. They have definetly helped me through some tough times this semester. That being said, I need some help here.

I am taking an Intro to Computer Science Class at a local community college. Its about a 35 minute drive every Tuesday and Thursday morning. I havent been able to go as of late because I have a full-time job as Video Producer and Graphic Designer. I work for a small publishing company and have some big very important release dates coming up.

My brothers wedding is also this Saturday and my fiance and I are still planning our wedding which is coming up very soon!

The only reason i'm taking this class is because at college, this is a prerequisite for HTML course. Doesn't make any sense to me either but its the hand I'm dealt with.

I am not a computer Science Porogramming and never will be.

I need help with this assignment. The assignment is due Thursday.

The assignemt is:

Write a Program that reads the integers between 1 and 100 and counts the occurrence of each number. Assume the input ends with 0.

**Note** if a number occurs more than one time, the plural word "times" is used in the output.

ITS IN C++ FORMAT, WRITTEN IN THE DEV C++ Program!

Heres the coding I have so far:

Code:

```#include <iostream> #include <cstdlib> #include <string> using namespace std; int inVal = 0;// for the entry of each value int valTally[100] = {0};// a place to store the counts for each number which could be entered. {     string num = "";     char search = '0';     int i = 0;     int count = 0;         do {         cout << "Enter a value of 1-100 (0 to quit): "; cin >> inVal;     // check that inVal is in range so the array bounds aren't exceeded         // tally the value }while(inVal != 0);         for (i = 0; i < num.length(); i++)     {         //cout << num[i] << endl;         if ( num[i] == search )         {             count++;         }     }         cout << endl << "Number of occurences: " << count << endl;         system("PAUSE");     return 0; }```
• 04-12-2011
rdrast
What do you have for your " // tally the value " area? that is sort of important, and simple.
Add 1 to the counter for whatever number is entered.

Used the way you are, num[100] cannot tally a value entered of 100. Maybe you want to increase the upper bound of num a bit so you can work more easily in natural numbers?

You aren't using "time" or "times" in your output.
From the description of the problem, you want something like:

The number 5 occurs 1 time.
The number 11 occurs 23 times.
• 04-12-2011
jimblumberg
Do you have any problems/questions about the posted code?

Does the code compile without errors/warnings?

If not post the complete error/warning message.

Is the program producing the desired output?

Give us a small sample of the input required to run the program and then tell us what output the program is producing and what you think this program should produce.

Jim