online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include "gcd.h" #include <iostream> #include<stdio.h> #include <stdlib.h> using namespace std; int main(){ long a,b; cout<< "enter the 1st no.: " << endl; cin>>a; cout<<"enter the 2nd number.: "; cin>>b; cout << " the gcd of " <<a<<" and "<<b<<" is " <<gcd(a,b); return 0; }
#ifndef GCD_H #define GCD_H /** * Calculate the greatest common divisor of two integers. * Note: gcd(0,0) will return 0 and print an error message. * @param a the first integer * @param b the second integer * @return the greatest common divisor of a and b. */ long gcd(long a, long b); #endif
#include "gcd.h" #include <iostream> using namespace std; long gcd(long a, long b) { //if a and b are both zero, //print an error and return0 if ((a==0) && (b==0)) { cerr <<"warning: gcd got both arguments 1"; return 0; } //a,b both are non negative if (a<0){ a=-a; } if (b<0){ b=-b; } //if a is zero the ans is b if (a==0) { return b; } //check the possibilites from 1 to a long d =0; for (long t=1; t<a; t++){ if ((a%t==0) && (b%t==0)){ d=t; } } return d; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue