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

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

Posted Date: 9/26/2012 7:53:10 AM | Location : United States







Related Discussions:- Find max and min no.from numbers passed through command line, Assignment Help, Ask Question on Find max and min no.from numbers passed through command line, Get Answer, Expert's Help, Find max and min no.from numbers passed through command line Discussions

Write discussion on Find max and min no.from numbers passed through command line
Your posts are moderated
Related Questions
Pre-order integration on Shopify store We are looking for on-call developers who can integrate Celery on client Shopify stores. Requirements a) Contented editing Shopify them

using UML 1- Identify primary classes 2- Scenario description 3- Class diagrams 4- Sequence diagrams

1- Allocate array with 32bit 100 element 2- Prompt the user to enter the maximum or the upper bound of the random value 3- Read the value and use it generate random numbers to init

how to save bulk entries at a time using collections?

Design an application that opens and analyses word files. Requirements: Create an application that analyses text documents. It should open a text file, read each word into an ap

The first task is to extend the  NeoPhoneBookEntry and  NeoPhoneBook classes to accommodate for  four additional contact  details:  Ringtone,  Vibration Pattern,  Led Pattern  and

ADO. NET ADO.NET (ActiveX Information Things for .NET) is a set of programs elements that developers can use to accessibility data and data solutions. It is an element of the platf

Example : Find the general solution to the subsequent differential equation. x 2 y′′ - 7 xy′ + 16 y= 0   Solution First the roots of (3)  r (r -1) - 7r + 16= 0 r 2

Complete the following program to move a value of 0xFFH to PORTB LIST p=18f4550 #include org 0x0000 movlw 0x00 _________ movlw 0xFF movwf PORTB end .