Consider the following COBOL entries 05 X PIC 99 VALUE 10. ADD 40 X TO X. COMPUTE X = 3 * X - 40. The result in X is (a) 10 (b) 40 (c) Compile or Run time error (d) none of these

This question is related to TCS Interview

Showing Answers 1 - 24 of 24 Answers

The answer is that you are chained to your desk debugging the program until you realize that any defined variable must be capable of handling the largest possible value.You're just lucky you didn't decide to loop on that variable until it reaches 1000.

RTMkk

  Was this answer useful?  Yes

NAGARAJ

  • Sep 21st, 2007
 

ans: (c) compile or run time error
05 level numbe is a group variable,it cant be used as a elementary variable

  Was this answer useful?  Yes

aravindhan

  • Oct 8th, 2015
 

D. Because ADD 40 10 TO 10 -> 50. X=3*50-40 -> 110.

  Was this answer useful?  Yes

madan

  • Oct 22nd, 2015
 

10

  Was this answer useful?  Yes

laxman

  • Dec 22nd, 2015
 

110

  Was this answer useful?  Yes

Gkoottar

  • May 11th, 2016
 

The add statement takes both, parameter and the number. So first 40 will be added to x then the result will be added to x, so x is now 60. next x is multiplied by 3 to 180. Then 40 will be subtracted giving the final result of 140

  Was this answer useful?  Yes

Saranya

  • May 28th, 2016
 

Add statement will add 40+10(value of X)+10(value of X) and the result will be stored in X as 60. Then, the compute statement multiples the value of X by 3 and subtract by 40. So, the value of X will be (6*3)-40=140. As the variable X declared with PIC 99, the value 140 cant be stored into variable X. So, will get Compile or Run Time error.

  Was this answer useful?  Yes

sadiks

  • Jun 21st, 2016
 

Answer is 40 - value of X is 10 -- add 40+10+10 = 60 ---> x=(3*60)-40 = 180 -- but pic declared as 99 -- right to left move so Answer is 40

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions