It looks like a possible divide by zero error.
There are a number of integers declared but not initialised.
At line 29
val1= rand () % val1 + 0;
has not been initialised, its value is garbage. The expression
first calls the function rand(), then attempts to divide by val1. If val1 happens to be zero, that can give an error.
Actually, I think that line should use
On a related area, since difval was not assigned an initial value and the switch-case statement does not have a default clause, then difval may still contain garbage.
Also, the variable
has not been initialised, it contains garbage. It's a good idea to always
initialise variables before attempting to use them.
How to start identifying problems such as this.
First compile with all warnings on, and pay attention to them.
From the Devc++ menu, select
tools->compiler options-> general
Check the box "add the following commands when calling the compiler:" and add the following:
-std=c++11 -Wall -Wextra -pedantic-errors
Secondly, you can use the debugger to step through the code line by line to identify the exact point at which it crashes (in this case, at line 29).