### Using Euclid's algorithm

$\gcd(a,0) = a$
$\gcd(a,b) = \gcd(b, a \,\mathrm{mod}\, b)$,
where
$a \,\mathrm{mod}\, b = a - b \left\lfloor {a \over b} \right\rfloor$.
If the arguments are both greater than zero then the algorithm can be written in more elementary terms as follows:
$\gcd(a,a) = a$
$\gcd(a,b) = \gcd(a - b,b)\quad,$ if a > b
$\gcd(a,b) = \gcd(a, b-a)\quad,$ if b > a

Code to find the Greatest Common Divisor of two numbers.



int GCD(int a,int b)
{
while(b^=a^=b^=a%=b);
return a;
}

unsigned greatestCommonDivisor(unsigned m, unsigned n)
{
if(n == 0) return m;
return greatestCommonDivisor(n, m % n);
}
If we know the greatest common divisor (GCD) of integers a and b, we can calculate the LCM using the following formula.
 LCM(a,b) = a × b GCD(a,b)

### C Questions

C Questions
C Questions

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:

void main()
{
int const * p=5; printf("%d",++(*p));
}
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
main()
{
char s[ ]="man"; int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
aaaa nnnn
Explanation

### Zoho Interview | Set 1 (Advanced Programming Round)

Third Round: (Advanced Programming Round) Here they asked us to create a “Railway reservation system” and gave us 4 modules. The modules were:
1. Booking
2. Availability checking
3. Cancellation
4. Prepare chart
We were asked to create the modules for representing each data first and to continue with the implementation phase.

My Solution :