Functions

This is a very basic program that I was copying from a book, but it will not work. It is supposed to simply take the number you insert into it, send the information to the function and then output it. However, my computer tells me simon has not been defined yet when I try and compile the program. (When I learned some Java a while back I learned that functions are variables, or at least like a variable.) So I assumed that the issue occurs because I places the function "simon" after "main". However, I thought that was supposed to be proper form, so my question is why is this error occurring?

Thanks,
-heyyouyesyouiloveyou

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
#include <iostream>
#include <cmath>


int main()
{
    using namespace std;
    
    simon(3);
    cout << "Pick an integer: ";
    int count;

    cin >> count;
    simon(count);
    cout << "Done!" << endl;
    
    return(0);
}

void simon(int n)
{
    using namespace std;
    
    cout << "Simon says touch your toes " << n << " times." << endl;
}
Last edited on
I went over my code again, turns out I had forgotten the function prototype at the top; I managed to miss that 10 times somehow.
Topic archived. No new replies allowed.