C Online Compiler
Example: C Program to Find GCD of Two Numbers using While loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Find GCD of Two Numbers using While loop #include <stdio.h> int main() { int p, q; // p & q - To store the two positive numbers printf("-----Enter the two positive integer numbers-----\n"); scanf("%d %d",&p, &q); while (p != q) { if (p > q) { p -= q; } else { q -= p; } } printf("\nThe GCD number is: %d\n", p); return 0; }
172 90
Output
Clear
ADVERTISEMENTS