Cの学習を始めたばかりなので、なぜこれが起こっているのかわかりません。
#include <stdio.h>
int square(int x);
int main(int argc, const char * argv[])
{
printf("Enter a number");
int userNum;
scanf("%d", &userNum);
int result = square(userNum);
printf("The result is %d", result);
}
int square(int x){
int result = x*x;
return result;
}
It would ask for a number but then nothing would happen after I input. If I were to take the scanf out and put square(10)
or something, the code will run and finish.