Hi.can any body give me the code for this quesiton
please.Because i dont have to try to enter the code in to
the AS/400 server.Please can anybody give the answer for
this question with complete code?
A smple RPLE pgm which accepts the starting number and
ending number as parameter.It then has to count all the odd
numbers b/w the accepted range of numbers and display the
results/

Ex:if the input parameters are 11 and 30 the result should
be 10(11,13,15,17,19,21,23,25,27,29)

Please explain and give me the complete code?

Answers were Sorted based on User's Feedback



Hi.can any body give me the code for this quesiton please.Because i dont have to try to enter the ..

Answer / arijit

Please try the below code:

D @StartNum S 3S 0
D @EndNum S 3S 0
D #Counter S 3S 0
D #LoopCnt S 3S 0
D #Result S 50A
*
C *Entry Plist
C Parm @StartNum
C Parm @EndNum
*
C Eval #Result = '('
C Eval #LoopCnt = @StartNum
C Eval #Counter = 0
*
C DoW #LoopCnt < @EndNum
C If %REM(#loopCnt:2) =
1
C Eval #Result = %TRIM(#Result)
+
C %TRIM(%CHAR
(#LoopCnt)) + ','
C Eval #Counter = #Counter +
1
C
ENDIF

*

C Eval #LoopCnt = #LoopCnt +
1
C
EndDo

*

C Eval %SUBST(#Result:%Len(%Trim
(#Result)):1) = ' '
C Eval #Result = %CHAR(#Counter)+%
TRIM(#Result)+')'

*

C #Result
Dsply
C EVAL *InLr =
*On

Is This Answer Correct ?    2 Yes 0 No

Hi.can any body give me the code for this quesiton please.Because i dont have to try to enter the ..

Answer / arun kumar

D Start S 3S 0
D End S 3S 0
D Count S 3 0
D Temp S 3 0
D Rslt S 3 0
D Rslt1 S 3 0
C *Entry PLIST
C PARM Start
C PARM End
/Free
Eval Temp = Start;
Eval Count = Start;
DoW Count <= End;
If %Rem(Temp:2) <> 0;
Rslt1 = Rslt1 + 1; //Number of ODD Numbers
Rslt = Rslt + Temp; //Sum of ODD Numbers
EndIf;
Temp = Temp + 1;
Count += 1;

EndDo;
Dsply Rslt1;
Dsply Rslt;
*InLR = *ON;
/End-Free
C** *InzSR BegSR
C** EndSR

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More IBM AS400 AllOther Interview Questions

How many PARM statement can we use in a CL program?

6 Answers  


what do we can do with the embedded sql statements?

0 Answers   IBM,


all i need to know about cmpseqdat parameter in cmppfm, how it works and can we retrieve line sequence and date from the output?

0 Answers  


define the rcvf command?

1 Answers   IBM,


What is the default value for the number of increment for the physical file?

1 Answers  






what is difference between accespath and datapath? what is the difference between accespath and open datapath?

2 Answers  


define a output queue?

1 Answers   IBM,


which of the cl command can be used to determine which logical files are dependent on a specific file?

0 Answers   IBM,


1.what is mean by compilation and runtime error? 2.How to define ALFA numeric value in pf? 3.what command is used to define a data in cl pgm? 4.What type of command is used in page at a time subfile and load all subfile?

2 Answers  


how to define global parameter in ile ?

0 Answers   IBM,


What does SDA stands for ?

1 Answers  


which are control break logic indicators?

0 Answers   IBM,


Categories