Given that you are manipulating matrices, my first guess would be that somewhere you are overrunning the bounds of some array, but you will have to figure out exactly which line of code is at fault. If you don't know how to use a debugger, your best chance is to put a print statement, e.g.:
halfway through the program, & see if it is printed before it crashes. Just keep moving it around until you pinpoint the error. If you find the line that is at fault & still don't know why, you can post just that line & maybe we can help.
printf("didn't crash yet\n");