943,789 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4946
  • C++ RSS
Oct 9th, 2003
0

Noob help!

Expand Post »
I stared at it for about a good 30 minutes now and I still can't find anything wrong with it. Can someone help?

C++ Syntax (Toggle Plain Text)
  1.  
  2. /*This program makes all vowels uppercase.
  3.   All other constants are lowercase.
  4.   Keep in mind I make to call a function
  5.   isvowel() to evluate the character.*/
  6.  
  7. #include <stdio.h>
  8. #include <ctype.h>
  9.  
  10. int isvowel(int ch);
  11.  
  12. int main(void)
  13. {
  14. int ch;
  15. while(ch=getchar()){
  16. if(isvowel(ch)==1)
  17. putchar(isupper(ch));
  18. else
  19. putchar(islower(ch));
  20. }
  21. return 0;
  22. }
  23. int isvowel(int ch)
  24. {
  25. if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
  26. return 1;
  27. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Weezer is offline Offline
2 posts
since Oct 2003
Oct 10th, 2003
0

Re: Noob help!

Try saying

C++ Syntax (Toggle Plain Text)
  1. int isvowel (int ch)
  2. {
  3. if (ch=='a' || ch=='e' || ch=='i' || ch=='o' ||ch=='u')
  4. return 1;
  5. return -1;
  6. }
Reputation Points: 13
Solved Threads: 0
Junior Poster in Training
Valmian is offline Offline
82 posts
since Sep 2003
Oct 10th, 2003
0

Re: Noob help!

didn't work
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Weezer is offline Offline
2 posts
since Oct 2003
Oct 10th, 2003
0

Re: Noob help!

C++ Syntax (Toggle Plain Text)
  1.  
  2. #include<iostream.h>
  3.  
  4. bool isVowel(char);
  5. char toUpper(char);
  6.  
  7. int main()
  8. {
  9. char my_letter;
  10. cout << "Enter character: ";
  11. cin >> my_letter;
  12. cout << toUpper(my_letter);
  13. return (0);
  14. }
  15.  
  16. bool isVowel (char letter)
  17. {
  18. bool to_return = false;
  19. if ((letter=='a') || (letter=='e') || (letter=='i') || (letter=='o') || (letter=='u'))
  20. to_return = true;
  21. return (to_return);
  22. }
  23.  
  24. char toUpper(char letter)
  25. {
  26. if (isVowel(letter)) letter -= ('a' - 'A');
  27. return (letter);
  28. }
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: problems wid cpp files
Next Thread in C++ Forum Timeline: Interpretation of an instructors C++ program...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC