IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

[Solved]How to calculate total no of Bytes


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ragin

New User


Joined: 20 Feb 2005
Posts: 16

PostPosted: Thu Mar 31, 2005 9:05 am
Reply with quote

Hi frndz,
I need the following o/p with calculation of how to calculate the total no of bytess in the following:
01 rec1 .
02 a pic x(6).
02 b redefines a.
03 c occurs 6 times pic 9.
02 d occurs 4 times.
03 e pic x(5).
03 f pic 999.

Answer:
a)38.
b)44
c)14
d)32



Now i need to know how to calculate total no of bytess in the above prog.i need it with calculation.kindly update me ASAP.
Back to top
View user's profile Send private message
gorle_n4

New User


Joined: 11 Mar 2005
Posts: 8
Location: hyderabad

PostPosted: Thu Mar 31, 2005 11:45 am
Reply with quote

01 rec1 .
02 a pic x(6).
02 b redefines a.
03 c occurs 6 times pic 9.
02 d occurs 4 times.
03 e pic x(5).
03 f pic 999.

here b is a redefining a so same memory will be shared so there it is occupying only 6 bytes
c is a group element and d is an elementary item of c. (6+4=10)
e=5
f=3
6+10+5+3=24
so answer is 24
Answer:
a)38.
b)44
c)14
d)32
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Thu Mar 31, 2005 1:18 pm
Reply with quote

Quote:
Hi frndz,
I need the following o/p with calculation of how to calculate the total no of bytess in the following:
01 rec1 .
02 a pic x(6).
02 b redefines a.
03 c occurs 6 times pic 9.
02 d occurs 4 times.
03 e pic x(5).
03 f pic 999.


hi friend the answer is 38.
A and b sharessame space.It is 6.

Dcontains 8*4=32
heceit is 38
Back to top
View user's profile Send private message
rsshanmugam

New User


Joined: 08 Mar 2005
Posts: 62
Location: Basildon

PostPosted: Thu Mar 31, 2005 7:06 pm
Reply with quote

hai friend the answer is 38 here we go how it happened



01rec1 .
02 a pic x(6).
02 b redefines a.
03 c occurs 6 times pic 9.
02 d occurs 4 times.
03 e pic x(5).
03 f pic 999

6 + 4 * 5 + 4 * 3 = 44 . since b redefines a they share same space
Back to top
View user's profile Send private message
satyanarayana.chitneni

New User


Joined: 28 Mar 2005
Posts: 4
Location: hyderabad

PostPosted: Fri Apr 01, 2005 1:50 pm
Reply with quote

Hi friends,

rsshanmugam is right .
Back to top
View user's profile Send private message
satyanarayana.chitneni

New User


Joined: 28 Mar 2005
Posts: 4
Location: hyderabad

PostPosted: Fri Apr 01, 2005 2:08 pm
Reply with quote

Hi,

Let me know where the 'c' will be stored?

'b' redefines 'a' means both variables adress is same, additional space(additional elementary items of 'b') of 'b' will be appended to space of 'a'.


So i hope 44 is the right answer.

Please give me clear answer whether i am right or not.

Regards,
Satya
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Fri Apr 15, 2005 8:13 pm
Reply with quote

Quote:
Hi,

Let me know where the 'c' will be stored?

'b' redefines 'a' means both variables adress is same, additional space(additional elementary items of 'b') of 'b' will be appended to space of 'a'.


So i hope 44 is the right answer.

Please give me clear answer whether i am right or not.

Regards,
Satya

HI Satya Where u find aditional space.
Back to top
View user's profile Send private message
maverick05

New User


Joined: 14 Apr 2005
Posts: 54
Location: Earth

PostPosted: Sat Apr 16, 2005 9:41 pm
Reply with quote

Hi Satya,

You have mentioned 6 + 4 * 5 + 4 * 3 = 44 . But i think
6 + 4 * 5 + 4 * 3 = 38. Just check the calculation.Correct me i am wrong as i'm weak in maths
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Apr 17, 2005 8:50 pm
Reply with quote

HI Satya,

The 6 occurences of the 1 byte c occupy the same space as the 6 byte a.

BTW guys, to avoid confusion, it's best to use parens "()" when showing arith, e.g.:

6 + ( 4 * 5) + (4 * 3) = 38

or more closely describing the record layout:

(1)6 + ( 5 + 3)4 = 38 the numbers within the parens rpresent the
lengths of each elementary item; the numbers
outside the parens represent the occurs.
Back to top
View user's profile Send private message
Chandukc

New User


Joined: 25 Apr 2005
Posts: 2

PostPosted: Mon Apr 25, 2005 12:30 pm
Reply with quote

Shanmugam is correct,but the equation he has given is wrong I think.Coorect me if I'm wrong.
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Tue Apr 26, 2005 2:55 pm
Reply with quote

Hi,


01 rec1 .
02 a pic x(6). (6 Bytes)+
02 b redefines a. (same memory so 0)+
03 c occurs 6 times pic 9. (same memory child so 0)+
02 d occurs 4 times. (4*8=32 total child length)+
03 e pic x(5). (5)
03 f pic 999. (3)


So 38 is the answer...

Tip: You can use Calculator to calculate the length.

Thanks,
Reddy.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
No new posts Build a trailer with total an count SYNCSORT 6
Search our Forums:

Back to Top