C Program to find Greatest of two number using command Line programming

C Programming Language / Command Line Arguments

1061

Program:

// Program by atnyla
// Find Greatest of two number using command Line programming

#include <stdio.h>

int main(int argc, char *argv[])

{

    int c[10];

    int i,temp,j,greatest;

    j = 0;

    for(i=1; i<argc; i++)
    {

        temp = atoi(argv[i]);

        c[j] = temp;

        j++;
        
    }

        greatest = c[0];

        for (i = 0; i < 10; i++) {

        if (c[i] > greatest) {

            greatest = c[i];

         }

        }

        printf("Greatest of ten numbers is %d", greatest);

  return 0;

}

Output:

12 16

Greatest of ten numbers is 16

Explanation:

Nope

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.