Hello,
I am trying to compute the GCD non-recursively. I have no errors but when I run the program it aborts because it says c is not intlized.
#include "stdafx.h"
#include "stdio.h"
int main (void)
{
int a,b,c,r,result;
printf("enter a value for a\n");
scanf ("%d", &a);
printf("enter a value for b\n");
scanf ("%d", &b);
printf("The result is %d\n", c);
{
int c;
if (a < b)
c = a;
a = b;
b = c;
return 0;
}
while(1)
{
c = a%b;
if(c==0)
return b;
a = b;
b = c;
}
}
Please help me find this issue!