Old Mcdonald program

Why am i getting error her ?

void Verse(string animal, string noise)
{
cout << "Old McDonald had a farm, " ;
cout << "Ei-igh , Ee-igh, oh !"<< endl;
cout << "And on his farm he had a " << animal << " , ";

cout << "With a " << noise << " " << noise << " here " << endl;
cout << "And a " << noise << " " << noise << " there " << endl;

cout << "Here a " << noise << " , "
<< " there a " << noise << " , "
<< " everywhere a " << noise << " " << noise << endl;
}


int main()
{
string animal;
string noise;

cout << " Enter the name of an animal : " ;
cin >> animal;

cout << " Enter noise that a " << animal << " makes :" ;
cin >> noise;
Verse (animal , noise);
return 0;

}
Student assignments are clearly getting more educational!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>                    // <===== you will need this for input/output
#include <string>                      // <===== you would be better having this if using strings

using namespace std;                   // <===== EITHER: put this here,
                                       //        OR:     qualify everything that needs it (e.g. std::cout)

void Verse( string animal, string noise )
{
   cout << "Old McDonald had a farm, "
        << "Ei-igh, Ee-igh, oh!" << endl;

   cout << "And on his farm he had a " << animal << "," << endl;

   cout << "With a " << noise << " " << noise << " here "  << endl
        << "And a "  << noise << " " << noise << " there " << endl;

   cout << "Here a " << noise << ", " << endl
        << "There a " << noise << ", " << endl
        << "Everywhere a " << noise << " " << noise << endl;

   cout << "Old McDonald had a farm, "           // The version I remember ended like this
        << "Ei-igh, Ee-igh, oh!" << endl;
}


int main()
{
   string animal;
   string noise;
   
   cout << "Enter the name of an animal: " ;
   cin >> animal;
   
   cout << "Enter noise that a " << animal << " makes: " ;
   cin >> noise;
   Verse( animal, noise );

// return 0;                         // not actually needed in main()

}


Enter the name of an animal: cow
Enter noise that a cow makes: moo
Old McDonald had a farm, Ei-igh, Ee-igh, oh!
And on his farm he had a cow,
With a moo moo here 
And a moo moo there 
Here a moo, 
There a moo, 
Everywhere a moo moo
Old McDonald had a farm, Ei-igh, Ee-igh, oh!
Hello lastchance ,
Thanks for help !

Regards,

Topic archived. No new replies allowed.