0
Can anyone help, i was assigned to write a c++ program that counts number of letters from one to one-thousand
5 odpowiedzi
+ 6
Please explain ur question clearly
I can't understand the '1 to 1000' part
+ 5
Writing a program that spells out number is great, and useful, but counting each letter of each word of the spelling? your lecturer is a killer I must say (pardon the word). What good would it do? I just can't understand.
Here's an idea, once you get the spelling part done, use a 2 dimensions array, it should have 26 elements, each element represents a letter (a-z).
You then use the first dimension to store the uppercase letter presence statistics, and the second dimension to store lowercase letter presence statistics. Imagine the array as follows:
------------
D1 D2
------------
A a
B b
C c
D d
E e
F f
G g
H h
I i
J j
...
Z z
Every time you find a letter 'A' increment the value of the first element from the first dimension, and every time you find a letter 'a' increment the value of the first element from the second dimension, and so on.
It's just an idea, not even a suggestion, you can ignore it and find your own way to do it, I would never mind. If it looks more trouble than helping I'm sorry, it's just an idea after all.
Hth, cmiiw
+ 3
@Sejeng Letsie, I remember seeing someone posted a code for spelling number, shame I didn't bookmark the code, I guess you can try searching the Code Playground for some others' work from which you can learn and adopt.
Best of luck!
+ 1
like if i wrote numbers from 1-1000 in words, and then count each letter of every word, then finally find the sum.
0
Thanks, i'll look into your idea more and see if it works... and i pray that it does..