-
2 function prototypes
i am trying to come up with function prototypes for 2 functions. here is what i have:
1. a function Symbol() that takes a character value x and returns a
Boolean value.
2. a function that displays 3 spaces to the standard output stream
cout.
answers
Code:
1. bool Symbol(char c);
2. void three_spaces( );
are these correct?
-
Well... yes, but I have a few questions. First off, #1 says a character value x, which even though x is just a generic symbol for a value of the variable, I would take as saying the char identifier should be x. You made it c. There is nothing wrong with that, but for the sake of being explicit, the identifier x might be better. That's just me, though.
For #2, I couldn't help but notice you have 3 spaces in between your parenthesis. Did you think that had anything to do with how it would output the three spaces? It's correct because it doesn't take arguments as it shouldn't, but when you don't have any arguments it's best that you just write
Code:
void func();
// ...or better yet
void func(void);
-
> a function that displays 3 spaces to the standard output stream
As in being able to write
cout << "hello" << three_spaces() << "world" << endl;
-
thank you the c was just a typo it should have been x