The code below works out the area under a curve using a series of trapezium's areas. This means that the x coordinates must be in increasing order (y coords dont have to be).

If an x value is entered that is less than the previous the code breaks and doesnt ask for the next x value, but DOES ask for all the y values. How can i rewrite this code so that it breaks completely, asking if the user wants to try again?

Code:#include <stdio.h> int main() #define N 15 { int i, sets; float x[N], y[N], area; char again='Y'; while(again=='y'||again=='Y') { area=0; printf("This is a program to integrate using the trapezium rule\n"); printf("Enter the number of coordinate sets you wish to use, up to %d\n\n", N); scanf("%d",&sets); if(sets<=15 && sets>0) { printf("\nType in %d values for the x coordinates\n", sets); for(i=0; i<=sets-1; i++) { scanf("%f", &x[i]); if(x[i] < x[i-1]) { printf("The value you entered is less than the previous\n\n"); break; } } printf("Type in %d values for the y coordinates\n", sets); for(i=0; i<=sets-1; i++) scanf("%f", &y[i]); for(i=0; i<sets-1; i++) { area = area + ((x[i+1]-x[i])*(y[i]+y[i+1]))/2; } printf("area is %f\n\n", area); } else printf("\nYou have entered an invalid integer\n\n"); printf("Would you like to run the program again?\n"); printf("Type Y or y for yes, anything else for no\n"); again=getchar(); if(again=='\n')again=getchar(); } return 0; }