#How to implement a palindrome and number of vowels after function main?

20 messages · Page 1 of 1 (latest)

copper meadow
#

There is a given line of code in the instructions, however. Am I suppose to confirm if it's true since bool data type was stated on the given code. The code that has been provide in the instructions can't be altered. Can you help me?

fair kelpBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

short laurel
#

After the main function is where you would write the function definitions

#

Could you clarify your question? I'm not entirely sure what you are asking

main junco
#

For the love of humanity, why? 😢
Using just about everything C++ gives you, except for string.

main junco
#
char str1[20]; // <<< this
cin >> str;
#

Listen, not your fault.
Teacher just gave you lemons, so make lemonade.

copper meadow
#

Oh, like I will make the definition of the function after main?

#

is that it?

main junco
#

Yes, that's what I took from your screenshot.

Make no modifications to the existing code.
But add code underneath it all.

#

Lines 4 and 5 give you the prototypes for the functions that you must add.

If you compiled the code as-is you would get linker errors in relation to these two functions.

copper meadow
#

I really don't get it, I've been scheming other sources. Is this code provided involves recursion?

short laurel
#

Nope

#

Basically function prototypes or declaration and function definitions are different.
Prototypes simply say "there is/will be a function with this name expecting these arguments return this type"
Function definitions actually determine what the functions does

#

The given code has the prototypes, now it is up to you to create the definitions

main junco
#

@copper meadow I will give a little example to hopefully help make the penny drop.

void printSomething(char* msg); // this is a prototype
int main()
{
  printSomething("Nice to meet you");
  return 0;
}

void printSomething(char* msg)
{
  puts(msg);
}
#

Keep in mind that a compiler reads your code like you read a book; from top to bottom.
It does not jump around to find your stuff.

So when it comes a line in the code where a function is called, then that function must already be known to the compiler at that time.
If it is not then you will get a compiler error.

You have two choices:

  1. put that function in its entirety above main()
  2. forward declare (a.k.a. prototyping) the function ahead of main() and provide implementation after main().

Your teacher steers you towards (2) and has provided you with the partial implementation.
It's up to you to provide the implementation. You need to do this for two functions.

#

And yes; I am basically parroting what @short laurel just said (apologies).

fair kelpBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.