You are right. I could only find examples of do while loops and I have been searching for a long time. I have been trying to not use a loop in the macro like this
Code:
#include<stdio.h>
#include<math.h>
#define fact(x)(factorial=factorial*k)
#define comb(answer)(result/(input*last))
main()
{
int n,k=1,x,result,diff,input,answer,last,factorial=1;
printf("Please enter a value for n \n");
scanf("%i",&n);
printf("Please enter a value for k \n");
scanf("%i",&k);
if (n<k)
printf("N must be larger than or equal to K \n");
else
{
diff=n-k;
for(k=1; k<=n; k++)
{
result=fact(n);
}
for(k=1; k<=n; k++)
{
input=fact(k);
}
for(k=1; k<=n; k++)
{
last=fact(diff);
}
printf("%i \n",result);
printf("%i \n",input);
printf("%i \n",last);
printf("The combination of %i things taken %i at a time is %i \n",n,k,comb(answer));
}
return 0;
}
but it is not working correctly. The first loop is gets the right answer but the next loops don't so I am not sure if this is even a correct setup. I feel like I am on the right track though so hopefully something will click soon.