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

}
                        

🖥 Program Output

12 16

Greatest of ten numbers is 16
                            

📘 Explanation

Nope
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.