#include<stdio.h> // Author- Khadiza Sultana // 10/8/2024 // Determing GCD of two integers using loop int main() { int a, b; // take two integers as input printf("Enter the integers:"); scanf("%d %d", &a, &b); while (b!=0) { int remainder = a % b; //1. Determining the remainder of a/b a = b; //2. storing b into a b = remainder;//3. storing remainder into b } printf("The GCD of the two integers is: %d", a); // 'a' holds the GCD after the loop return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter