Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

I've a question about Programming in the language C..?

I am trying to write a basic program in C and as I am a beginner I could use some help. I need to learn this material fast and I'm having a lot of trouble. If someone could help me out with the following that'd be great.

Everything below is supposed to be done with basic C commands only which is restricted to strings, arrays, loops such as for and if loops, and pointers and basic commands like that. I am really lost and would appreciate some code help.

1.

Create a new C function which will count the number of vowels (A, E, I, O or U, capital or lower case) in a string passed to it, and return that number (as an "int"). Note that the type of the string passed into this function should be "const char *" - as strings are really arrays of "char"s - which, in turn, are really constant pointers to "char"s).

Add to your main program several test calls to this function, and print out the strings passed in and the responses to the screen. Be sure to check any corner cases you can think of.

2.

Add another C function to your program which returns nothing (void), but takes two writable strings and compares them. If the first is alphabetically (see here) after the second, then your function should completely swap the contents of the two strings before returning. It is the caller's responsibility to be sure the memory the strings reside in is writable and that there is enough space in the array holding each to hold the other should they need to be swapped (and you should note these limitations in the comments for this function).

Note that this sort should NOT be case-sensitive (so neither "Ape" nor "ape" is alphabetically after the other). Non-letters should be entirely ignored and skipped (so neither "ape" or "432a--P. E++" is alphabetically after the other). Also, shorter words should be sorted before longer words which contain that entire shorter word at their beginning (so "fish" comes before "Fisher").

Add to your main program several tests of this, outputting the results of each.

3 Answers

Relevance
  • Mike R
    Lv 4
    1 decade ago
    Favorite Answer

    I'd love to help you but posting your homework is a bad idea. Asking for general help or tutorials will help you out a lot more.

    That being said, here's a tutorial for you: http://www.physics.drexel.edu/students/courses/Com...

  • ?
    Lv 4
    5 years ago

    There is not anything incorrect with finding out C++ as a primary programming language. C++ is an overly robust programming language, so this is a first-rate alternative. There is not any such factor as a "no-opt for novices". The persons who say so both lacked the intellectual talents to gain knowledge of C++ or are the ones variety of persons who best recommendation what they understand and what they think is quality. Any programming language which has stuck your eye is first-rate for a newbie. If you've began finding out C++ it might be a waste to change to another programming language, as the whole thing you've discovered hence a ways is wasted. Simply stick to C++.

  • 1 decade ago

    One of the things beginning programming students need to learn is not to panic because they don't understand something. You need to learn to look things up in your book and apply them.

    First, you have to understand the problem. Your first function just counts vowels. No problem. How many vowels are in "hellothere"? How did you figure that out? Well, now you just have to write the steps down, one by one, on the process of counting the vowels. Next you look up the code for each step for your function.

    I'll get you started on step by step:

    1) get first letter

    2) is letter a vowel? if yes, then add to count

    3) get next letter or if end of string go to 5)

    4) go to 2)

    5) return count

Still have questions? Get your answers by asking now.