Hello, I have problems with creating program like this:
Input five pairs of nunbers and input menu:
-----
1. GCD
2. LCM
0. CLOSE
Input option:
1
Input number of selected pair of numbers:
1

print result and print menu again.
It suppose on input there isn't different number and everything should be realized by
custom separated functions.

I created this, but I don't know how to finish it, please could you help me?
Code:
```#include <stdio.h>
#include <stdlib.h>

unsigned int nsd(unsigned int m, unsigned int n) {
if (n==0) return m;
else return nsd(n,m%n);
}

int lcm(int a,int b) {
int n;
for(n=1;;n++) {
if(n%a == 0 && n%b == 0)
return n;
}
}

int i;
printf("%s\n%s\n%s\n%s\n%s\n%s\n", "MENU", "-----", "1. Nejvetsi spolecny delitel",
"2. Nejmensi spolecny nasobek", "0. KONEC", "Zadej operaci:");
i = getchar();
if (i==1) {
unsigned int vysledek_nsd, m, n;
m = getchar();
n = getchar();
vysledek_nsd = nsd(m, n);
printf("%u", vysledek_nsd);
}
if (i==2) {
//nsn();
}
if (i==0) return 0;
if (i!=0 && i!=1 && i!=2) {
return -1;
}
return 0;
}

int main(void) {

/*int i, j, pole[2][5];
for(int x=0; x<5; x++) {
scanf("%d%d", &i, &j);
for(int c = 0; c<2; c++) {
for(int k = 0; k<5; k++) {
pole[i][j] = c;
}
}
}
for(int c = 0; c<2; c++) {
for(int d = 0; d<5; d++) {
pole[c][c]++;
printf("Nejake cislo: %d a druhe cislo %d\n", i, j);
}
}
*/
if(vysledek == -1) return -1;

return EXIT_SUCCESS;
}```

2. Welcome to the forum, maestrom!

If you have a menu function, then EVERYTHING will branch out (or start to branch out), from the menu().

a BIG do while loop, which is called just ONCE, from main(). All the other functions will be called from here, and returned here when they're done.

Code:
```void menu(void) {

int choice=0;

do {

print the choices for the user to choose from:

1) GCD,

2) etc.

3) etc.

etc....

5) Exit

select (choice) {

case 1:
//code here for choice 1 - calling other functions.

break;
case 2:
//code here for choice 2  -   ditto
break;
case 3:
//code here for choice 3  -     ditto
break;
case 5:       //just an exit
break;
default:
}

} while(choice != 5);
}```
See if that makes sense to you.

3. But functions must be out from main, please help me more sophisticated, this solution looks good, but I am not so good in C yet.

Thank you for your help, friend.

4. I'm going to add a few things to it, but really, it's up to you, at this point, to work on it.

You can't learn to read without actually reading, and you can't learn to code in C, without a good deal of practice.

Code:
```#include <stdio.h>

int main(void) {

return 0;
}

int choice=4,num1,num2,lcmultiple;

do {

print the choices for the user to choose from:

1) GCD,

2) LCM

3) etc.

etc....

0) Exit

printf("Enter your choice [1-3 or 0 to Exit]: ");
scanf("%d",&choice);

select (choice) {
case 0:
printf("\n\nGoodbye\n\n");
break;
case 1:
printf("Enter the first number to find the LCM of:  ");
scanf("%d", &num1);
printf("And now enter the second number: ");
scanf("%d", &num2);
lcmultiple=lcm(num1,num2);
printf("The LCM for %d and %d is %d\n",num1,num2,lcmultiple);
break;
case 2:
//code here for choice 2  -   ditto
break;
case 3:
//code here for choice 3  -     ditto
break;
default:
}

} while(choice != 0);

}```
That's a good start, for sure! Run through the C tutorial by clicking on the C Tutorial tab at the top of this forum - it has a LOT of really good info in there!

5. Thank you, but my greatest problem is implementation of input and choose of those pairs of numbers, please could you write here, how could I do that I don't understand how to use with it in the functions and menu.

Thank you very much.

6. Originally Posted by maestorm
Thank you, but my greatest problem is implementation of input and choose of those pairs of numbers, please could you write here, how could I do that I don't understand how to use with it in the functions and menu.

Thank you very much.
Input is included in the code I posted above, for two numbers. If you don't understand it, run through the C tutorial which is linked at the tab with that name, at the top of this forum.

Now it's your turn to get to work - you need to practice, not have someone else code for you the rest of the way.

Time to get busy, my friend!