Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
HOW TO WRITE TRIANGLE PROGRAM LIKE C IN THE COBOL?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rayeshu

New User


Joined: 21 Jun 2006
Posts: 3
Location: ahemadbad

PostPosted: Tue Jul 04, 2006 6:40 pm    Post subject: HOW TO WRITE TRIANGLE PROGRAM LIKE C IN THE COBOL?
Reply with quote

HI,
ALL HEY I WANT MY OUTPUT LIKE THIS(LIKE WE DO IN C PROGRAMMING WITH 2 FOR LOOPS).
*
* *
* * *
* * * *
* * * * *
MAY I USE LIKE

DISPLAY (ROW, COL) "*"? IT WILL GIVE ERROR....
Back to top
View user's profile Send private message

parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Wed Jul 05, 2006 1:35 pm    Post subject:
Reply with quote

I think, following pseudo code will do this for you.


Code:

 WORKING-STORAGE DECLARATION.
*===========================
 01 WS-STARS-LINE     PIC X(80) VALUE ALL '*'
 01 WS-LINE           PIC X(80) VALUE ALL SPACES.
 01 I                 PIC 9(03) VALUE ZERO.

 PROCEDURE DIVISION.
*===================

    PERFORM UNTIL I = NO-OF-LINES
       MOVE SPACES              TO WS-LINE.
       MOVE WS-STARS-LINE(1: I) TO WS-LINE.
       ADD 1 TO LINE-NUM
       DISPLAY WS-LINE
    END-PERFORM
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Wed Jul 05, 2006 5:07 pm    Post subject: Re: HOW TO WRITE TRIANGLE PROGRAM LIKE C IN THE COBOL?
Reply with quote

Hi rayesh,

Hope the following code will do !!!!

Code:
    IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIPGM.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77 N PIC 9 VALUE 0.
       77 I PIC 9 VALUE 1.
       77 STR PIC X VALUE "*".
       77 J PIC 9 VALUE 0.
       PROCEDURE DIVISION.
       PARA.
           DISPLAY " ".
           DISPLAY "ENTER THE LIMIT VALUE ".
           ACCEPT N.
           PERFORM PARA1.
       PARA1.
          PERFORM PARA2 VARYING I FROM 1 BY 1 UNTIL I >= N.
       PARA2.
          PERFORM PARA3 VARYING J FROM 1 BY 1 UNTIL J >= I.
       PARA3.
          DISPLAY (I,J) "*".

Output

Quote:

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



Quote:
DISPLAY (ROW, COL) "*"? IT WILL GIVE ERROR....


I m not getting such error's .....
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jul 16, 2006 8:49 am    Post subject:
Reply with quote

This should work.

Code:

01  star-line      pic  x(010) value '*'.
01  pos            pic s9(001) value +1 comp.

perform do-stars 5 times
stop run
.
do-stars.
    display star-line
    add +1   to pos
    move '*' to star-line(pos:1)
    . 
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us