Please login


Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

Command Line Programming For Greatest of Two numbers

Find Greatest of two number using command Line programming?

It is highly advisable to go through Command Line Arguments Post before even looking at the code. Please study this for TCS and come back to this post later.

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



            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;


Other TCS Coding Questions –

2 comments on “Command Line Programming For Greatest of Two numbers”