Find max and min no.from numbers passed through command line, Programming Languages

Assignment Help:

10.     W.A.S.S to find maximum and minimum number from numbers passed through command line.

 

Program

 

# W.A.S.S to find maximum and minimum number from numbers passed through command #line.

 cnt=$#

# //$# gives the count of total number of command line arguments

 

if [ $cnt -gt 0 ]

then

min=$1

max=$1

 for i in $* # $* stores the command line arguments

 do

  if [ $i -gt $max ]

  then

   max=$i

  elif [ $i -lt $min ]

  then

   min=$i

  fi  

 done

 

echo "Minimum is : $min"

echo "Maximum is : $max"

else

 echo "Enter the command arguments properly:"

fi

 

Output

 

sh cmdline.sh 23 12 45

Minimum is : 12

Maximum is : 45


Related Discussions:- Find max and min no.from numbers passed through command line

Create single page to demonstrates an xhtml form, Create a single page that...

Create a single page that demonstrates an XHTML form. The form should include all the fields you feel are necessary for submitting an order of books and must include at least one

Create a structure to represent deck of cards, We want to create a structur...

We want to create a structure that will represent a deck of cards (not necessarily full). Each card has a character (between '2' to '9' and 'T', 'J', 'Q', 'K', 'A') and a suit (dia

Define the syntax of for loop, Define the Syntax of FOR Loop? The unive...

Define the Syntax of FOR Loop? The universal form of this statement is for(initialization;condition;increment/decrement)             { statements;             }

How to create an html document?, An HTML document may be created via any HT...

An HTML document may be created via any HTML editor or text editor such as notepad etc.

Matlab, Determine the moment of force about the point where a bracket is at...

Determine the moment of force about the point where a bracket is attached to a wall. the bracket is shown in figure attached. it extends 10 inched out from the wall and 5 inched up

Define an example of switch statement, Define an Example of Switch Statemen...

Define an Example of Switch Statement? estimate(number) int number; /* Estimate a number as none, one, two, several, many */ {       switch(number) { case 0 :

Included applications, Hi, Can any of you, tell me how to use Included Ap...

Hi, Can any of you, tell me how to use Included Applications?

Programme for create the class in the karel++ , Create the class Robot desc...

Create the class Robot described in the Karel++ book. Description: The Robot class described in the Karel++ text is a derived class of ur_Robot. Create class Robot as a d

Miranda, Hi, Can you do exercises: D2, D3, D4, and D5 on page 230 of the fo...

Hi, Can you do exercises: D2, D3, D4, and D5 on page 230 of the following book: http://www.daimi.au.dk/~bra8130/Wiley_book/wiley.html . The book can be downloaded for free from t

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd