0
C++Functions problem
I follow all rules in code but every time chatbot said try again
6 Answers
+ 4
Roshni Vishwakarama ,
without having seen your code we cannot see what the issue is.
please put your code in playground, save it, create a link to the code file and post this link here.
+ 2
Roshni Vishwakarama ,
you should now do what the task description says:
> implement an input for a string inside the bot() function. store input in a variable.
> then the output should not be *hardcoded* like in the current code, but output should be a concatenation of the expected text + the input (variable) of the name + the exclamation mark.
+ 1
When writing a function in c++ you should always follow a certain ruleset:
1. Your function's name should only start from latin letters(a-z) or underscore
2. Your function should follow C++ syntax template:
return_type function_name() {
//body of the function
//return;
}
Where return_type must be specified and have a type what exists in c++ i. e types like: int, float, std::bool or user defined types.(UDT's).
If return_type is void return keyword is optional as function does not return a value.
In parenthesis - (), you can specify parameters for you function which follow same naming rules as variables and fumctions.
You should also check your function definition and place where you calling the function because C++ is case sensitive.
For example given code:
void Foo() {}
foo();
Will give an error as Foo and foo functions are not the same thing.
+ 1
Roshni Vishwakarama ,
running your code in *sololearn playground* does not raise any issue.
maybe the output is not as expected, or your code should take a user input.
it would be helpful if you could share the task description here.
0
My code:
#include <iostream>
using namespace std;
void bot() {
cout << "Welcome, Amy!" ;
}
int main (){
bot();
}
Chat bot always saying try again .
0
Define the bot() function, so that it takes a string as input .The input is Amy