// 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;
}
12 16
Greatest of ten numbers is 16
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.
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.