Problem with functions

im new to c++, and im having trouble with functions, can someone please explain to me and maybe provide a fix to this code. thanks beforehand.

#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
int pow(int, inr);
cout<<"Please enter your first number"<<endl;
cin>>firstnumber;

cout<<"Please enter your second number"<<endl;
cin>>secondnumber;

power= pow(firstnumber,secondnumber)


{

int power (int x, int y);
cout<<x<<endl;
cout<<y<<endl;

return power ;
}

system ("pause");
return 0;
}
really need help
Your code seems a bit muddled. For one thing, it looks like an attempt to define one function inside another, that's not possible.

This is a general idea of how it might look, though I've not attempted to use your example.
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;

int square(int);

//----------------------------------------
int main ()
{
    int number;

    cout << "Please enter a number" << endl;
    cin >> number;

    int squ = square(number);
    cout << "Square of " << number << " is " << squ << endl;

    system ("pause");
    return 0;
}

//------------------------------------------

int square(int x)
{
    return x * x ;
}
Topic archived. No new replies allowed.