Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 

even number code

Former Member
0 Kudos

Hi ,

i am writing code for getting even numbers from 1 to 100.

biut i am always getting 0.

below i am writing my code if any one can correct me.

data : n type i value 0,

m type i .

do 100 times.

n = n + 1.

*m = m + 1.

m = ( n mod 2 ).

if m = 0.

write πŸ˜• 'even',m.

endif.

enddo.

regards,

karan

1 ACCEPTED SOLUTION

ThomasZloch
Active Contributor
0 Kudos

> write πŸ˜• 'even',m.

->

> write πŸ˜• 'even',n.

10 REPLIES 10

ThomasZloch
Active Contributor
0 Kudos

> write πŸ˜• 'even',m.

->

> write πŸ˜• 'even',n.

Former Member
0 Kudos

dude .... u are display the value of M man ... display 'N' ...

data : n type i value 0,

m type i .

do 100 times.

n = n + 1.

*m = m + 1.

m = ( n mod 2 ).

if m = 0.

write πŸ˜• 'even',n.

endif.

enddo.

Thanks,

Aditya. V

Former Member
0 Kudos

correct code

data : n type i value 1,

m type i .

do 100 times.

n = n + 1.

*m = m + 1.

m = ( n mod 2 ).

if m = 0.

write πŸ˜• 'even',n. "change line

endif.

enddo.

abdul_hakim
Active Contributor
0 Kudos

Here is the code for you.

data: no1 type i,

no2 type i.

do 100 times.

no1 = no1 + 1.

no2 = no1 mod 2.

if no2 eq 0.

write:/ 'Even:', no1.

endif.

enddo.

Cheers,

Hakim

Former Member
0 Kudos

HI,

data : n type i value 0,

m type i .

DO 50 TIMES.

M = N MOD 2.

IF M = 0.

WRITE:/ N,

'EVEN'.

ENDIF.

N = N + 1.

enddo.

Former Member
0 Kudos

Hi,

you can simply do like this:

data : n type i.

do 50 times.

n = 2 * sy-index.

write πŸ˜• 'even', n.

enddo.

Regards,

Neha

Former Member
0 Kudos

Hi,

You can do like this also.

DATA : n TYPE i.

DATA: a TYPE i VALUE 0.

WRITE 'List Of Even Nos.'.

DO 50 TIMES.

a = a + 1.

n = 2 * a.

WRITE / n.

ENDDO.

Thanks

Former Member
0 Kudos

dont forget to mark the thread as answered once ur issue gets solved

former_member224008
Active Participant
0 Kudos

hi karan,

data : n type i value 0,

m type i .

do 100 times.

n = n + 1.

*m = m + 1.

m = ( n mod 2 ).

if m = 0.

write πŸ˜• 'even',m. "change to write πŸ˜• 'even',n.

endif.

enddo.

regards,

ARUN

0 Kudos

This message was moderated.