FIRST:
You should not be using printf() and scanf() in c++... those are c functions and you should instead use cout and cin... because they are more secure.
SECOND:
In function square why did you make a new variable... you could just put return x*x;
THIRD:
before the return you put getch... why? did you want to pause the program... but for what... cin pauses for input.... or did you want the user to see the results... because there is nothing to print it out.
Anyway getch like printf and scanf is from c and the safer more reliable c++ version is cin... you could put cin.get to replace it.
Fourth:
return EXIT_SUCCESS;????We want a int... and you could just put 0 which usually means success.... or did you put a #define EXIT_SUCCESS 0 in the code?
Finally your code should look like this.
#include <conio.h>
#include <iostream>
int square(int x)
{
return x*x;
}
int main(int argc, char *argv[])
{
int a;
int x;
std::cout << "what are you waiting for, just enter your number\n";
std::cin >> a;
x=square(a);
std::cout << x << "\n";
std::cin.ignore();//Ignores previous input, get cin.get working even with new line inputs.
std::cin.get();
return 0;
}
PS: Your code did work.... but did not pause or print out the output... also in the cmath header there is a sqrt() function which would work very well in this situation.