What am I doing worng? Segmentation fault, core dump
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main( )
{
int x;
int y;
int choice;
printf ( "Hello! This is the second version of my calculator\n" );
printf ( "Select addition or subtraction\n" );
printf ( "1.Addition\n2.Subtraction\n");
scanf ("%d", choice);
if ( choice = 1 )
{
printf ( "You chose addition\n" );
printf ( "Input first integer\n" );
scanf ("%d", x);
printf ( "Input the second one\n" );
scanf ("%d", y);
printf ("%d", x + y );
}
}
I do not have a code for choice 2, but why doesn't choice 1 work?
What am I doing wrong????
It just gives me a core dump, segmentation faul error after I choose 1