ok im doing this other program on for loops for greatest common divisor, so the problem is i cant seem to display the common divisor of both numbers, so i seem to be having problems with the formula inside the for loop, so it doesn't work is there anything im missing

Code:

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int g,n,m,i;
printf("Give me two numbers separated by space (p>q): ");
scanf("%d %d",&n,&m);
for(i=0;i<=n%m;i++){
g=n%m;
g=m%n;
}
printf("The GCD of %d and %d is %d ",n,m,g);
getchar();
getchar();
}

also another question how can i do to insert two numbers in one enter (insert two numbers just by spacing them?)