test

This is a discussion on test within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Code: #include <iostream> using namespace std; char isVowel(char ch); int main() { char ch; cout << "Please enter a letter ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    5

    test

    Code:
    #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;
    	else 
    		cout << "Not a vowel" <<endl;
    	return 1;    
    }

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    a) This belongs on the C++ board.
    b) You have not asked a question or given any reason for posting your code.
    c) if(char ch = 'a') is always true because you can always do that assignment
    -- use if(x == 'a') and look into the or ( || ) operator
    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
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Nice use of code tags, though.
    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.

  4. #4
    Nosepicker DrakkenKorin's Avatar
    Join Date
    Nov 2001
    Posts
    407
    not to mention, there's no error trapping.
    DrakkenKorin

    Get off my Intarweb!!!!

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,335
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Integer Emulation
    By Elysia in forum C++ Programming
    Replies: 31
    Last Post: 03-18-2008, 01:03 PM
  2. undefined reference
    By 3saul in forum Linux Programming
    Replies: 12
    Last Post: 08-23-2006, 05:28 PM
  3. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  4. MSVC Template Constructor/Assignment Errors
    By LuckY in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:57 PM
  5. Question About Linker Errors In Dev-C++
    By ShadowMetis in forum C++ Programming
    Replies: 9
    Last Post: 08-18-2004, 08:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21