Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

PROGRAM TO DISPLAY TRIANGLE OF NUMBERS

Posted By: Volker Fischer     Category: Cobol     Views: 6490

PROGRAM TO DISPLAY TRIANGLE OF NUMBERS.

Code for PROGRAM TO DISPLAY TRIANGLE OF NUMBERS in Cobol

       Identification Division.
       Program-Id. Display-of-Pattern-No-1.

       Environment Division.

       Data Division.
       Working-Storage Section.
       77 N       Pic 9.
       77 Counter Pic 9 Value 1.
       77 j       Pic 9 Value 1.

      * The Designing of the Main Screen of the Program.

       Screen Section.
       01 Main-Screen.
           02 Blank-Screen.
           02 Line 2 Column 15 "The Pattern to be Displayed is : "
             Reverse-Video Blink.
           02 Line 4 Column 15 "1".
           02 Line 5 Column 15 "2  1".
           02 Line 6 Column 15 "3  2  1".
           02 Line 7 Column 15 "4  3  2  1".
           02 Line 10 Column 15 "Please Enter the No. of Lines for the a
              "bove Pattern :".
           02 Line 10 Column 70 Pic 9 To N.

       Procedure Division.

       Main-Para.
           Display Main-Screen.
           Accept Main-Screen.
           Move 12 To Lin.
           Move 15 To Col.
           Perform Lines-Loop Varying Counter From 1 By 1 Until
           ( Counter > N ).
           Stop Run.

      * The Main Loop of varying the Lines is Below.

       Lines-Loop.
           Perform Display-Loop Until j < 1.
           Add 1 To Lin.
           Move 15 To Col.
           Compute j = Counter + 1.

      * The Main Loop of Displaying the Pattern is Below.

       Display-Loop.
           Display(Lin, Col) j.
           Add 3 To Col.
           Compute j = j - 1.

                                                                      
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM TO DISPLAY TRIANGLE OF NUMBERS Or get search suggestion and latest updates.

Volker Fischer
Volker Fischer author of PROGRAM TO DISPLAY TRIANGLE OF NUMBERS is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!