HCF/GCD of two numbers using Command Line Arguments

Ques. Find the GCD of two numbers using command line arguments program?

Here is the program for gcd of two numbers using command line arguments check other sections for TCS on our website.

#include
int main(int a,char *b[])
{
    int num1,num2,min,i,gcd=1;
    if(a!=3){
        printf("Enter two argument\n");
        exit(1);
    }
    num1=atoi(b[1]);
    num2=atoi(b[2]);
    min=(no1<no2)?no1:no2;
    for(i=1;i<=min;i++)
    {
        if((num1%i)==0 && (num2%i)==0)
            gcd=i;
    }
    printf("GCD of two number %d",gcd);
    return 0;
}
Summary
Review Date
Reviewed Item
Command Line Argument GCD
Author Rating
51star1star1star1star1star