Shell script to print pyramid, Programming Languages

Assignment Help:

Shell Script to print pyramid

 

Program

 

#W.A.S.S. to create pyramid

 

echo -e "enter num:\c"

read n

j=1

k=1

 

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

do

 

  j=$k

 

  while test $j -lt $n         #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

       *
      *  *
     *  *  *
    *  *  *  *
   *  *  *  *  *
  *  *  *  *  *  *
 *  *  *  *  *  *  *

      

 

 


Related Discussions:- Shell script to print pyramid

Get variable data, How do i get back data from a FOR loop in order to prin...

How do i get back data from a FOR loop in order to print them on screen?

ATM, The ATM will simulate a real world automated teller machine that suppo...

The ATM will simulate a real world automated teller machine that supports safe access to accounts from multiple concurrent clients.

programming assignment using perl, This assignment is an individual progra...

This assignment is an individual programming assignment using Perl. It addresses objectives 3, 4, 5 and 8 as listed in the Subject Outline document. The assignment is based on them

Define parameter passing mechanism - computer programming, Define the Param...

Define the Parameter Passing Mechanism - Computer Programming? The Parameters are syntactically identifiers and they are used within the body of the function and sometimes the

Produce a hierarchy chart-a structured flowchart, Produce a hierarchy chart...

Produce a hierarchy chart, a structured flowchart, and a Pascal program (with appropriate comments) to generate the Sales Commission Report shown below. The commission for each sal

Design and implement schemasusing xml schema, You are to build a Schema in ...

You are to build a Schema in XML Schema Language that will be used to support the development of the new central course information management system and other supporting applicati

NETLOGO , THERE IS ANY1 COULD HELP ME WITH NETLOGO WORK

THERE IS ANY1 COULD HELP ME WITH NETLOGO WORK

Create a structure that will represent a deck of cards, We want to create a...

We want to create a structure that will represent a deck of cards  (not necessarily full). Each card has a character (between  '2'  to  '9' and  'T',  'J',  'Q',  'K',  'A') and a

Develop a program on behavior of hospital personnel, A psychologist is inte...

A psychologist is interested in learning about the voting behavior of college students.  (4 points for each part.)Design a study which would yield data on this topic. a. state y

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd