If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: isvowel function

Re: isvowel function

As it stands, your program shouldn't compile as isVowel(..) is supposed to return a type bool but the function doesn't have a return statement! Also, your main function should return a value as well (usually 0).

I forgot to indent as I was working,

Indenting of code as you enter/change it should become second nature. It makes reading and understanding it so much easier - especially when it comes to trying to work out why a program doesn't function as expected.

All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

Re: isvowel function

Originally Posted by 2kaud

As it stands, your program shouldn't compile as isVowel(..) is supposed to return a type bool but the function doesn't have a return statement!

It only results in undefined behaviour, hence a compiler might still compile the program. However, it probably would result in a warning, so... psfign: consider increasing the warning level of your compiler.

Originally Posted by 2kaud

Also, your main function should return a value as well (usually 0).

That's optional since a missing return statement for the global main function would be as if return 0; was present at the end.

Re: isvowel function

I don't know how to do the return statement

To return a value from a function, the return statement is used. The format is

return val;

where val is the data you want to return and has the same type as that defined with the function definition. In your case isVowel(.) needs to return a value of type bool which is true if ch is a vowel and false otherwise.

All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!