I'm searched about this but haven't found anything conclusive. I recently started compiling from the command line and it creates an executable. I'm using a Mac by the way... Anyhow, one of the programs I wrote for school executes, asks for the two integers to be input, but then, it just disappears!
I need my terminal window to stay open so that I can at least see that my program works correctly!
// Program Assignment 1 - Least Common Multiple
// Desc: simple program to display LCM of two read integers
int findLCM(int, int);
void getNums(int*, int*);
printf("The Least Common Mutiple of %d and %d is:\t%d", a, b, findLCM(a, b));
void getNums(int* a, int* b)
printf("This program will accept (2) positive integers and calculate the Least Common Multiple");
printf("\n\nEnter the first integer -> ");
scanf("%d", a); //Why does this 'a' not need an address operator '&' preceding it?
while (*a < 1) //Wanted to combine line 32 and line 33 but couldn't make it work. - Also, why does this 'a' need a '*' to work but the line 29 reference has nothing?
printf("\n\n*Integers MUST be positive. Enter the first integer -> ");
printf("\nEnter the second integer -> ");
while (*b < 1)
printf("\n\n*Integers MUST be positive. Enter the second integer -> ");
int findLCM(int a, int b)
for (i = 1; (i % a != 0) || (i % b != 0); i++)