Cobol code for displaying the output in the following format



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Tue Jan 26, 2010 1:36 pm

hai guys ,
can anybody help with me the cobol code for displaying the output in the following format.

*
* * *
* * * * *
* * * * * * *
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: cobol code

Postby Robert Sample » Tue Jan 26, 2010 4:50 pm

You want us to do your homework for you?

What have you tried so far and what are you having problems with?
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Cobol code for displaying the output in the following format

Postby dick scherrer » Wed Jan 27, 2010 1:54 am

Hello,

*
* * *
* * * * *
* * * * * * *
What does this mean? What is actually required? What kind of input is processed to get to this "output"?

We will help you solve your requirement, but you have to post the "rules" for the process and what you are having trouble with.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Sat Jan 30, 2010 11:05 am

procedure division.
accept n-------------------n is the number of lines to print stars(*).
compute 2n-1
perform varying k from 1 by 1 until k>n
perform varying i from 1 by 1 until i>n
perform varying j from 1 by 1 until j>(n-1)2+1
if j=(m+1)/2
compute p=(i-1)2+1
perform varying q from 1 by 1 until q>p
string '*' delimited by size into var1
else
string ' ' delimited by size into var1
end-perform
subtract 1 from m
end-perform
display var1
end-perform.
stop run.
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol code for displaying the output in the following format

Postby dick scherrer » Sat Jan 30, 2010 11:42 am

Hello,

Is there a question here?

I see no question and i see no "rules" - just some unclear pseudo-code.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Sat Jan 30, 2010 9:48 pm

is there any method to give the following output
var1 = i am working
var2
output should be

var1 = i
var2 = am working
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Sat Jan 30, 2010 10:02 pm

IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I PIC 9.
PROCEDURE DIVISION.
          PERFORM VARYING I FROM 1 BY 1 UNTIL I > 5
                   DISPLAY I
          END-PERFORM.
          STOP RUN.


THE ABOVE PROGRAM DISPLAYS THE OUTPUT IN THE FOLLOWING FORMAT.
1
2
3
4
5

WHAT SHOULD I DO TO GET THE OUTPUT IN THE FOLLOWING FORMAT.

1 2 3 4 5.

PLEASE TELL ME IF I MAKE ANY MISTAKES IN THE CODE.
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol code for displaying the output in the following format

Postby Robert Sample » Sun Jan 31, 2010 12:31 am

You have made no mistakes -- the code is doing exactly what you told it to do.

Find the COBOL Language Reference manual and read up on the COBOL DISPLAY statement -- you should be able to find what you need to know there.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Cobol code for displaying the output in the following format

Postby dick scherrer » Sun Jan 31, 2010 2:29 am

Hello,

WHAT SHOULD I DO TO GET THE OUTPUT IN THE FOLLOWING FORMAT.

1 2 3 4 5.


How does this relate to the original request? The original output appeared to "grow" as processing continued. This looks nothing like that. . . :?

If you want to combine data from multiple "inputs", you need to build the complete output line before you diswplay anything. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Cobol code for displaying the output in the following format

Postby kranthi.kumarmca22 » Sun Jan 31, 2010 10:21 am

thanks for that
kranthi.kumarmca22
 
Posts: 14
Joined: Thu Jan 07, 2010 9:50 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post