Shell script to print right traingle, Programming Languages

Right triangle

 

Program

 

#W.A.S.S. to create right  triangle

 

echo -e "enter num:\c"

read n

j=1

k=1

 

while test $k -le $n             #this loop print as many line of * as the value of k

do

 

  j=`expr $n - $k`

 

  while test $j -gt 0         #this loop print forward spaces in each line

  do

     echo -e "   \c"

     j=`expr $j - 1`

  done

 

  j=1

 

  while test $j -le $k      #this loop print as many * per line as the value of j

  do

     echo -e " * \c"

     j=`expr $j + 1`

  done

 

  echo " "

  k=`expr $k + 1`

done

 

Output

 

enter num:7

                   *

                *  *

             *  *  *

          *  *  *  *

       *  *  *  *  *

    *  *  *  *  *  *

 *  *  *  *  *  *  *

Posted Date: 9/26/2012 4:35:28 AM | Location : United States







Related Discussions:- Shell script to print right traingle, Assignment Help, Ask Question on Shell script to print right traingle, Get Answer, Expert's Help, Shell script to print right traingle Discussions

Write discussion on Shell script to print right traingle
Your posts are moderated
Related Questions
We need Advancement in Existing PhoneGap Application We need a PhoneGap expert to aid us extend an existing PhoneGap application. The app works pulls data from a new website (de

1.  A function that produces the Collatz sequence and counts the number of terms. 2.  A main function that calculates interesting values about the Collatz sequence. 1.The Col

.NET class library .NET structure comes with just one category selection. And that all developers need to learn!! Whether they create the value in C# or VB.NET or J#, it doesn't

Program for Operate the Rolodex Rolodex is a rotating file, usually used to record business contact information. Cards are inserted in alphabetic order by name. You operate th

Question : (a) Many systems provide support for both user threads and kernel threads, resulting in different multithreading models. What are the two differences between user

Who can help with MATLAB?

a program that enter an alphabet from the user and compare it is vowel or not?

Silver light uses WPF to provide included web handles Microsoft Technologies Silverlight uses WPF to provide included web handles similar to Adobe Display, but with more focus on a

What are Relative URLS ? When a web browser reads an HTML document, it has a great deal of information about the document. This includes the protocol used to retrieve the docu

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