-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finding the largest number using CLP
- Loading branch information
1 parent
cf0ea17
commit 8faa59b
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//Command Line Argument | ||
#include<stdio.h> | ||
|
||
/* | ||
* argc-Number of command line arguments | ||
* char *argv[]- List of command line arguments | ||
*/ | ||
int main(int argc, char *argv[]) | ||
{ | ||
int a, b, c; | ||
if(argc<4 || argc>5) | ||
{ | ||
printf("Enter 4 arguments!\n"); | ||
return 0; | ||
} | ||
|
||
//Converts string number to integer | ||
a = atoi(argv[1]); | ||
b = atoi(argv[2]); | ||
c = atoi(argv[3]); | ||
|
||
if(a<0 || b<0 || c<0) | ||
{ | ||
printf("Enter only positive numbers!\n"); | ||
return 1; | ||
} | ||
if(!(a!=b && b!=c && a!=c)) | ||
{ | ||
printf("Please enter different value \n"); | ||
return 1; | ||
} | ||
else | ||
{ | ||
if(a>b && a>c) | ||
printf("%d is largest\n",a); | ||
else if(b>c && b>a) | ||
printf("%d is largest\n",b); | ||
else | ||
printf("%d is largest\n",c); | ||
} | ||
} |