Menu system crashing for program

Hi new to C/C++ and needed help with a program. In this program I am supposed to take user input to find the area of curve by using the midpoint rule and trapezoidal rule the function for that i will be finding the area under is: f(x)=mx^3+nx^2+px+q. In the program i am to find the user input of m,n,p,q and then with both rules I have to find the interval from a to b and find how many rectangles(N) the user wants; this will be my delta x. Then I am supposed to display the results I got from both rules.

[code]
#include <stdio.h>
#include <math.h>
float m, n, q, p; // define these in global scope for function
float x;

int main()
{
int choice; // variable for switch statement
float area_trap, area_mid; // variables for coefficients, and integral values
float a, b, N, h; // variables for delta x

do
{
printf("Menu to calculate integrals\n"); // menu system for user
printf("___________________________\n");
printf("1)Enter new coefficients (m,n,q,p)\n");
printf("2)Enter the value for a, b, N\n");
printf("3)Calculate the integral from a to b\n");
printf("4)Exit\n");
scanf_s("%d", choice);

switch (choice) // switch statement so user can go through menu system
{
case 1: // finding the coefficients

printf("Enter new coefficients for m, n, q, p\n");
scanf_s("%f", m, n, q, p);
printf("(0). Return to main menu");
printf("\n");
break;

case 2: // find the values for a,b,N


printf("Enter the value for for a, b,N for delta x\n");
scanf_s("%f", a, b, N);
printf("(0). Return to main menu");
printf("/n");
break;

case 3: // calculating the areas


h = (b - a) / N; // calcualtes the trapezoidal function
area_trap = (f(a) + f(b))/2;

for (int i = 1; i > N; i++)
{
area_trap += f(a + i*h);
}
area_trap*= h;

for (int j = 1; j > N; j++) // calculates the midpoint function
{
area_mid += f(a + 1 * h);
}

printf("The area under the curve for midpoint rule is:8.2%f\n", area_mid); // print results of both areas
printf("The area under the curve for trapezoidal rule is:5.2%f\n", area_trap);

case 4: // exit statement


printf("Exit\n");
break;

default: printf("Error in input method\n"); // error statement for switch function
}
} while (choice != 4); // while for it to loop through once user is done with program can hit 4 to exit
return(0);
}

float f(float x) // function for f(x)
{
return m*x*x*x + n*x*x + p*x + q;
}

currently the program is able to display the menu but when i go to select my choice it just crashes. Any help would be much appreciated!
Topic archived. No new replies allowed.