2006 Dec 14 5:07 AM
Hi friends,
if ( ( n MOD 2 ) == 0 ).
when i say this in my syntax, it throws an error saying that mod is not supported. Can anybody tell me why. As far as i knw, it is the right syntax.
please correct me if im wrong.
Same is the error even for Div operator too.
im trying to display only even numbers in this particular program.
2006 Dec 14 5:08 AM
Hi friends,
if ( ( n MOD 2 ) == 0 ).
when i say this in my syntax, it throws an error saying that mod is not supported. Can anybody tell me why. As far as i knw, it is the right syntax.
please correct me if im wrong.
Same is the error even for Div operator too.
im trying to display only even numbers in this particular program.
2006 Dec 14 5:08 AM
2006 Dec 14 5:12 AM
Hi,
Please try this.
if ( ( n MOD 2 ) = 0 ).
...
else.
...
endif.
Regards,
Ferry Lianto
2006 Dec 14 5:19 AM
Hi ferrry,
thanx for your suggestion, but i trie with single "=" also, but i havnt got the output.
I got the answer to my question but what i need is that why the output is not displayed when i say n mod 2 = 0 is my query.
2006 Dec 14 5:34 AM
Hi Raghu,
When u say mod it means that the remainder is zero for e.g 4 MOD 2 = 0 ,
if this condidtion is satisfied then only the output is displayed.
Just Try out this.
report test.
parameter : p_n1 type i.
data : g_result type i.
compute g_result = p_n1 mod 2.
if g_result = 0.
write 'Remainder is zero'.
else.
write 'Remainder is not zero'.
endif
Regards,
Vaibhav B Gawali.
2006 Dec 14 5:41 AM
Thank you Pragya and Vaibhav.
<b>I did not knw that the mod and div operatoions can't be performed within the if condition</b>. Thank you Pragya for your answer.
And as for Vaibhav, thank you for your answer too. I know the logic and i already finished this report. But i wanted to knw why the mod was not working in the IF condition.
Thanks to you all, my doubt has been clarified.
Regards,
Raghu.
2006 Dec 14 5:33 AM
Hi Raghu,
we can not use mathematical computation in If expression.
you may calculate the vaue first and then can compare to zero.
e.g.
var2 = var1 mod 2.
If var2 = 0.
...
else
...
endif.
Regards,
Pragya
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |