Processing math: 100%
C-Programmierung

Kontrollstruktur While Gg T

Kontrollstruktur While Beispiele | | Kontrollstruktur Do-While

Der ggT(a,b) ist mathematisch definiert als

ggT(a,b)=ggT(b,a mod b)a,b>0.

Die Implementierung des ggT mit einer Schleife:

int a,b,c;

printf("input value: ");
scanf("%d", &a);

printf("input another value: ");
scanf("%d", &b);

/* greatest common divisor */
while (b>0)
{
   c=b;
   b=a%b;
   a=c;
}

printf("the gcd is %d!\n", c);


Kontrollstruktur While Beispiele | | Kontrollstruktur Do-While

Options: