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
#question.what. is cai? Explain its pitfalls .o

Question 1 Discuss on UNIX kernel components 2 Explain process creation and process termination 3 When do a Deadlock occur? What are the Necessary Conditions for Deadlock

You need to create a simple application for the Note Plus book Store. The interface for the application is shown below:   REQUIRED: 1)  Create all necessary contro

1. Modify your solution to #8 so that if an ellipse is touched by the mouse, it turns permanently green.Bonus (up to +5): a green ellipse stops moving, but recovers after 5 seconds

Write a booking and pricing system for seats for performances in a theatre. Design and write a system to handle information (equipment, people, events etc.) for a club. Given

Improved Application Deployment Data source implementation is perhaps the key to any Asp.net program implementation, and, if the database implementation is easily done, there is an


Consider the operation of a line of supermarket checkouts and the profiles of customers and their shopping baskets. Use a random number generator to create the data for these profi

Provide Example of Function? An illustration of a function definition main() { message(); } /* header */ message() { /*bodystarts here*/ printf ("Example for function

Microsoft's VC++ Windows V C++ was a highly effective device. But it was too complicated. It has too many information kinds, and designers had to understand many your local lib