far too many uninitialised variables, set things to 0 as often as you can, at least then you have a known value to work with. and at least as a basic protection against bad user input in this case., this thread is littered with examples of you just not taking any notice of good advice given.

and ay caramba :

What on earth do you think simplify will be?Code:int simplify(int x2 ,int y2 ,int gcd ,int a ,int b ) { a= x2/gcd; b= y2/gcd; return simplify; }