How to build an array containing all consonants in a string of lowercase text? No consonant should be repeated in the array even if it occurs more than once and print the number of consonants occurring?

Recommended Answers

All 5 Replies

Get to know the problem - really analyze it, in this case, by doing it by hand with paper and pencil.

After you get the steps down into small steps which you can readily identify, then write down those steps -- That's your pseudo code.

Check your pseudo code, that it's correct, and then put one small step onto one line, and see if you can make that logic, into actual C code.

Don't worry the details, for now. Get the "flow" of the program working. A function (or block of code), for input, for output, for processing, is common.

After you get the major logic code working, add in the details you put off, earlier.

And welcome to Top Down Design, and the forum. ;)

Post up your attempt at the above, and I'll show you a slick trick for programming the above. The reason is that programming is, after you get past the basics, a lot of problem solving. You have to get used to solving problems like this one, and the sooner you get into that, the better.

So, no code will I give you, right now. Work with it, and show what you come up with.

I did all of that, still having a problem......I just need a fragment of the code, then I can maneuver it to what I really have to do with it. Thanks for your help!!!

If you have your pseudo code written out, then post it up. Of course, I know you didn't do it, and you're bull-shitting me, but that's OK. Everyone will try the "I'll lie and he'll buy it maybe, what have I got to lose?", tactic.

I've been around far too long to believe it, but I'm hoping you'll say "damn that Adak, I'll write down some pseudo code, and post it, just to prove he's wrong", and that will be fine. ;)

Veracity may be scarce here, but believe this - I will *not* post so much as one semi-colon of code, until I see you post up some pseudo code or actual code. Doesn't matter which one.

Put some "skin" into this effort. Don't post up "still having a problem", post up your attempt, and state clearly and specifically WHAT the problem(s) is/are.

I want to help you, and I want to believe you. You're just not making that possible, so far.

commented: Very direct +4

It sounds like a typical introductory programming assignment.
No cheating!

Just to get past language issues, here are some tips:
An array of characters in most languages is called a "string".

1. a fixed, unchanging string in C/C++ can be declared like this:

static const char* fixed_array_of_characters= "fubar" ; // a few characters
static const int howmany = sizeof(fixed_array_of_characters)-1; // in this case, 5

2. you can get a character out of the string like this:

char B= fixed_array_of_characters[0]; // item zero is always first in a C array

3. you compare two single characters like this:

if( B == 'x' ) printf( "match!" );

4. you walk through a string like this:

char A;
for( int i= 0; i< howmany; ++i )
  A= fixed_array_of_characters[i] ; // this doesn't do anything except get one character

Thanks again for all your help.......I figured it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.