Error while running program

1
#include<stdio.h>
#include<math.h>

int main ( void ){
int x;
int i;
printf("Input the number (Table to be calculated) : ");
scanf("%d", x);

for( i = 1; i <= 10; i++){

    printf("%d x %d = %d", x, i, x*i);
}
return 0;

}

Would you like to know the reason for the error? I've tried creating a variable to hold the value of x * i inside the loop, but it still does not work, after I give the first input seen on the screen, Windows identifies a problem ...

    
asked by anonymous 20.12.2016 / 01:23

2 answers

5

After the first parameter, scanf expects to receive a reference to the variable that you want to save the value of the entry:

scanf("%d", &x);

I hope I have helped.

    
20.12.2016 / 01:29
-2

In addition to the "&" in "scanf" as already mentioned, you put in the main function the void and at the end of the code "return 0", and this is wrong because void does not return anything.

    
20.12.2016 / 05:03