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
In this activity, you are going to place components on a sheet and connect them with virtual wires to create a simple digital circuit. You will simulate the circuit to verify the c

Question 1 How to call a WML Script from a WML Page? Question 2 Write short notes on WML Script Operators and Expressions Question 3 Write short notes on WML Script Statements

Explain the applet Element ? Applets are embedded in web pages by using the and tags. The APPLET element is same to the IMG element. Like IMG APPLET references a source fil


( Airline Reservations System ) A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You are to w

Version Control is a critical tool in development and production environments that allows a user to make snapshots of working con?gurations or code. In this assignment, you will de

For the following Code answer the following questions-: .STACK 100H .DATA COUNT DB 10 TOTAL DW 4126H .CODE MAIN PROC MOV BX, 3F20H MOV AL, BL MOV BL, COUNT MOV

Develop a socket program in UNIX/Linux that uses (i) TCP as the transport protocol and  (ii) UDP as the transport protocol for transferring  a short message between a client and  s

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

On December 27, 2011, Seymour Gravel, at the urging of his wife, Mary Walford, has brought you his preliminary figures for his business. Seymour carries on a business writing and e