How do you correct this functions?

/*Write a C++ program that uses three user-defined functions
(counting main() as one) and produces the following output:

Three blind mice
Three blind mice
See how they run
See how they run*/

#include <iostream>
using namespace std;
void three();
void run();

int main(){
int x, y;
x=three();
y=run();
cout<<x<<endl<<y<<endl;

system("pause");
return 0;
}
void three(){
cout<<"Three blind mice\n";
cout<<"Three blind mice\n";
}
void run(){
cout<<"See how they run\n";
cout<<"See how they run\n";
}
For any function, you do not need to define extra variables within the main function. So your code should be able to compile this way:

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
#include <iostream>
using namespace std;

void three();
void run();

int main()
{

three();
run();

system("pause");
return 0;
}

void three()
{
cout<<"Three blind mice\n";
cout<<"Three blind mice\n";
}

void run()
{
cout<<"See how they run\n";
cout<<"See how they run\n";
}


Also remember that whenever you are writing code, format is key !

Steps to functions:
1. Initialize before main
2. Define after main
3. Use function within the main function

By the way, you forgot to read the instructions of the program, you are missing some of its requirements.
Last edited on
THANKS, but what did I missed in the requirement?
You did not follow the second one correctly. You redefined your functions within the main function, which is why it was probably not working.
Topic archived. No new replies allowed.