]> www.hackdaworld.org Git - my-code/beginners.git/blob - ggt.c
added string2bin
[my-code/beginners.git] / ggt.c
1 /* program to calculate the ggt of two integers */
2
3 /* we include headers */
4 #include <stdio.h>
5
6 main()
7 {
8
9 /* declaration of variables */
10 int zaehler, nenner;
11
12 printf("Zaehler: ");
13 scanf("%d",&zaehler);
14 printf("Nenner: ");
15 scanf("%d",&nenner);
16
17 if ( nenner == 0 )
18         {
19         printf("never devide through zero, lamer :p\n");
20         exit(0);
21         }
22 else
23         {
24         while ( zaehler != nenner )
25                 {
26                 if ( zaehler > nenner )
27                         {
28                         zaehler = zaehler - nenner;
29                         }
30                 else
31                         {
32                         nenner = nenner - zaehler;
33                         }
34                 }
35         printf("ggt = %d\n",zaehler);
36         }
37 }