You are on page 1of 1

ChatGPT 3.

You
Not using function

ChatGPT
Here's a simple C program to calculate the Greatest Common Divisor (GCD) of two
numbers without using a function:

c Copy code

#include <stdio.h>

int main() {
int num1, num2, gcd;

// Input two numbers from user


printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);

// Find GCD
for (int i = 1; i <= num1 && i <= num2; ++i) {
if (num1 % i == 0 && num2 % i == 0) {
gcd = i;
}
}

// Display GCD
printf("GCD of %d and %d is %d\n", num1, num2, gcd);

return 0;
}

This program calculates the GCD of two numbers without using a separate function.

Message ChatGPT…

ChatGPT can make mistakes. Consider checking important information.

You might also like