Page 1 of 3

Cobol code for displaying the output in the following format

PostPosted: Tue Jan 26, 2010 1:36 pm
by kranthi.kumarmca22
hai guys ,
can anybody help with me the cobol code for displaying the output in the following format.

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

Re: cobol code

PostPosted: Tue Jan 26, 2010 4:50 pm
by Robert Sample
You want us to do your homework for you?

What have you tried so far and what are you having problems with?

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

PostPosted: Wed Jan 27, 2010 1:54 am
by dick scherrer
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.

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

PostPosted: Sat Jan 30, 2010 11:05 am
by kranthi.kumarmca22
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.

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

PostPosted: Sat Jan 30, 2010 11:42 am
by dick scherrer
Hello,

Is there a question here?

I see no question and i see no "rules" - just some unclear pseudo-code.

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

PostPosted: Sat Jan 30, 2010 9:48 pm
by kranthi.kumarmca22
is there any method to give the following output
var1 = i am working
var2
output should be

var1 = i
var2 = am working

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

PostPosted: Sat Jan 30, 2010 10:02 pm
by kranthi.kumarmca22
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.

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

PostPosted: Sun Jan 31, 2010 12:31 am
by Robert Sample
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.

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

PostPosted: Sun Jan 31, 2010 2:29 am
by dick scherrer
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. . .

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

PostPosted: Sun Jan 31, 2010 10:21 am
by kranthi.kumarmca22
thanks for that