Home / Programs / C Program to find Greatest of two number using command Line programming
Programming Example

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

👁 1,017 Views
💻 Practical Program
📘 Step by Step Learning
C Program to find Greatest of two number using command Line programming

Program Code

// 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

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.