i need to write two separate functions
one is bool that checks if the input is valid
the other is a double function that does something else.
my professor wants that the double function returns to -1 if the input is invalid.
and he is going to grade the two functions by using assert()
in this case, should i bring the bool result from the bool function and write as "if (boolResult = 0) return -1"
or should I write the boolean expression for the second function and return -1 if it's invalid??
the bool function is really long so I prefer to bring bool function result to the double function
if i can bring the result, how can i write it??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include<iostream>;
#include<string>;
#include<cctype>;
using namespace std;
bool a(string s);
double b(string s, string word);
(omitted function descriptions)
string command;
string targetAir;
int main() {
cout << "Enter a string: ";
getline(cin, command);
cout << "Enter valid two alphabets to be detected in the string: ";
getline(cin, targetWord);
cout << "function a returns" << a(command) << endl;
cout << "function b returns" << b(command, targetWord) << endl;
return 0;
}
|