Having trouble with the functions code challenge 'introduction'

My code gives the correct output (Knowles, Beyonce Knowles) but for some reason I’m told it is incorrect.
Here is my code:

#include <iostream>
#include <string>

using namespace std;

// Define introduction() here:

void introduction(string first_name, string last_name){

cout << last_name << ", " << first_name << " " << last_name << endl;


int main() {

introduction(“Beyonce”, “Knowles”);


Any help is much appreciated!

Sometimes even when your code is correct, and will work perfectly, it doesn’t match the solution that the lesson is looking for. It appears that to earn the check mark to pass this challenge you have to use the expected syntax:

void introduction(std::string first_name, std::string last_name) {
  //code here

Your using namespace std; statement would be the preferred way to do it in a real world scenario, but this particular lesson is expecting the above.
Of course you’ll then also have to use std::cout and std::endl. It’s a pain, I know.


Ah I see. Thank you so much!


I originally learned some C++ from a few other venues several years ago. Don’t use it much, so I’m rusty. I proceeded to the next challenge, and found that you cannot enter any code that will pass without clicking the ‘Solution’ button. When I did, the solution was the same as my code. I copied the solution, reset the exercise, pasted the solution back in, and it still won’t pass. I have found a few cases like this in other languages on Codecademy. I submitted a ‘Bug Report’, and suggest you do the same if you have the same results I just did. Hopefully they’ll fix it. Good Luck! && Happy Coding!


@byteblaster72579 @midlindner this is great to know! added a hint to this exercise :slight_smile: