GeekInterview.com
Series: Subject: Topic:
Question: 1 of 55

Write a shell script that accept 7 numbers in loop

write a shell script that accept 7 numbers in loop,then make a sum of this numbers. then count the numbers that are greater than 250 ?
Asked by: angel rayan | Member Since Jun-2012 | Asked on: Jun 3rd, 2012

View all questions by angel rayan

Showing Answers 1 - 1 of 1 Answers
ardiansyah

Answered On : Jul 5th, 2012

Code
  1. #!/bin/bash
  2. total=0
  3. c=0
  4. for a in {1..3};
  5.   do
  6.         echo -n "Write a number : "
  7.         read i
  8.         if [ $i -ge 250 ] ; then let "c=c+1"
  9.         fi
  10.         let "total = i + total"
  11.   done
  12. echo "total = $total"
  13. echo " > 250 = $c "

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.