Given the following code, what will the output from the program be?


main record       result      ,d10.2      num1        ,d10.2       num2        ,d10.2 proc open(1,o,'tt:') num1 = 5.6 num2 = 3.7      writes(1, %string(AddTwoNumbers(num1,num2))) close 1 stop end

function AddTwoNumbers ,d       anum1 ,d.       anum2 ,d. proc       freturn anum1 + anum2 end



  1. It won’t compile
  2. Run time error
  3. 9.3000000000000000000000000000
  4. 9

At this year’s Synergy DevPartner  Conference, PSG Consultant Steve Ives did a session on using the unit testing capabilities built into Visual Studio for testing your code.  While the code for this particular quiz is simple, traditional Synergy DBL code, even this function could be added to a project with unit test cases that would allow you to check it for correct behavior.

Some will assume the program will not compile/link due to the function call without the preceding percent sign, but you may recall that newer versions of Synergy do not require a percent sign in front of functions.  (Yes, I included one in %string to potentially draw you into a trap!)

Therefore, this program will definitely compile, and it will also run, so (a) and (b) are not correct answers.  The parameters are correctly defined to take implied-decimal numbers, so you would probably think the result of this routine would be (c). In fact, though, the function is defined as type “d”, not “d.”, which means the function returns a whole number only. Thus, the correct answer is (d).

Presumably, if you were creating a routine like this one, you’d want the function to return the correct result. To accomplish that, simply change the function declaration to be of type “d.” instead of “d”, like this:

 function AddTwoNumbers ,d.

However, the point of this quiz is to re-emphasize the use of the unit testing built into Visual Studio to help you track down bugs of this nature, which may be subtle at times.  In previous versions, the testing capabilities in Visual Studio required one of the higher grade licenses, but now they are included with all versions of Visual Studio 2012.

Be sure to review the materials you received at the Synergy DevPartner Conference. This is just one of the many, many topics covered over the course of three days, so if you were not at the 2013 conference, please consider joining us next year!