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
Your task will be to code a simulation of image compression based on the approximate low rank structure of the set of image patches. You will write functions .code = my block compr

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Write your own version of the strcmp function string_compare. Supply a main program that will test each of the 3 differing outcomes. int string_compare(char *s, char *t); retu

In this question we will de ne a function for sorting lists based upon the algorithm selection sort. First, de ne a function smallest which takes as input a list of integers and r

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Please remember to read and follow all of the assignment guidelines. This assignment will expand upon the simulation algorithm given in class to produce a program which may be u

Redundant sequence identification: Given a set of k DNA sequences, S = { s 1, s 2, ... ,  s k } give an optimal algorithm to identify all sequences that are completely contained

How to create an ER diagram?

1. Implement a program where an ellipse follows the perimeter of the window. 2. Implement a program that can draw graphs, possibly following your plan from last week. Have it gr

If it is a weekday and it is not a holiday, then you go to work. However, if it is a weekday and it is a holiday, then what you do depends on the weather. If it is raining, you pla