Well you are printing "result" without initializing it or assigning it a value. Is result supposed to be your GCD ? Then you probably want to move your print to [B][I]after[/I][/B] you have computed your GCD and assigned it to the "result" variable.
Did you intend to have your "if" and "while" loop be separate functions or a part of the main function ? Since I see you are swapping "a" and "b" a < b and then trying to compute the gcd. With your code you'll never get to computing the GCD if that is the case !!