Thread: Help! I'm still learning

  1. #1
    Registered User
    Join Date
    Oct 2004

    Help! I'm still learning

    Alright, so the assignment for my entry level c++ class is to write a function isVowel in a program that can identify whether a letter entered by a user is a vowel or not. Here is what I have conjured up however know from looking at it I am very wrong in my approach, can somebody out there send me in the right direction, I cannot figure it out from my text and tutorials. Thanks for your input!
    #include <iostream>
    using namespace std;
    char isVowel(char ch);
    int main()
    	char ch;
    	cout << "Please enter a letter from the alphabet: ";
    	cin >> ch;
    	cout<<"the letter you have entered is: isVowel(ch)";
    	return 0;
    char isVowel(char x)
    	if (char ch = 'a')
    		cout << "A Vowel" <<endl;
    		cout << "Not a vowel" <<endl;
    	return 1;    

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    See my post to this in GD. Ignore a and b, though, and try to avoid cross posting.

    One other thing, make sure that your call to isVowel is not enclosed in quotes.

    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > cout<<"the letter you have entered is: isVowel(ch)";
    cout<<"the letter you have entered is: " << isVowel(ch);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Manassas, VA USA
    Pseudo boolean is_val() function:

    bool class::is_val(possibly pass in your string here)
         1) toupper(string)    //from the <cctype> library
         2) create a loop...  perhaps a 'while' loop or a 'for' loop with strnglen( ) as a parameter
         3) make a character-by-character == comparison         
         4) return true when   string[i] == ('A' || 'E' || 'I' || 'O' || 'U')
         5) else return false

    Hope this helps
    Last edited by The Brain; 10-08-2004 at 03:13 PM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  5. #5
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    And just so everything in that thread is in this thread...

    if (char ch = 'a')
    should be
    if (char ch == 'a')

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Machine Learning with Lego Mindstorms
    By DavidP in forum A Brief History of
    Replies: 14
    Last Post: 01-30-2009, 02:34 PM
  2. Need Help On a Simple Bank Program
    By oobootsy1 in forum C# Programming
    Replies: 9
    Last Post: 08-08-2005, 10:51 AM
  3. Fun Learning a New Language
    By UnregdRegd in forum A Brief History of
    Replies: 16
    Last Post: 09-30-2003, 10:03 PM
  4. Learning Rate Of C++
    By Krak in forum C++ Programming
    Replies: 27
    Last Post: 01-29-2003, 01:53 PM
  5. API learning reference (for those who are learning)
    By steve_i83 in forum Windows Programming
    Replies: 1
    Last Post: 11-04-2001, 01:58 AM