+ 1

c language code

#include <stdio.h> /* declaration */ int square (int num); int main() { int x, result; result = square(x); printf("enter your number here***"); scanf("%d",x); printf("%d squared is %d\n", x, result); return 0; } /* definition */ int square (int num) { int y; y = num * num; return(y); } what could be the problem with this program

17th Dec 2019, 2:53 PM
Isaiah
Isaiah - avatar
4 Answers
+ 2
Inside main() Write the result line after scanf method and include "&" before x inside the scanf. How come you take value of x and assign it to result without even taking user input.
17th Dec 2019, 3:00 PM
Avinesh
Avinesh - avatar
+ 1
There is no problem. Just run it and enter a number. https://code.sololearn.com/ca9uGs3Sc4Xb/?ref=app
17th Dec 2019, 4:48 PM
Avinesh
Avinesh - avatar
0
there is a problem when you run the program
17th Dec 2019, 2:54 PM
Isaiah
Isaiah - avatar
0
Have u tried it out
17th Dec 2019, 4:53 PM
Isaiah
Isaiah - avatar