0% found this document useful (0 votes)
9 views

ex13.

Uploaded by

omguelalta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

ex13.

Uploaded by

omguelalta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Analysis

.let N,N1,N2,d,l,i1,i2 seven integer variables

.we ask the user to input N

.we set N1 and N2 at 0 ; N1=0 N2=0

.we do the first operation( to find the LSB) which is l=N mod 10

.we de determine if l is even or not by this operation d=l mod 2

.if l is even (d=0) then we put the value of l in N1 ; N1=l

Otherwise we put the value of l in N2 ; N2=l

.we set i1 and i2 in the value 1 ;i1=1 i2=1

. To deal with the other digits we repeat the following operation while N is
greater or equals 10

-we remove the LSB of N ;N=N div 10

-we find the new LSB ; l=N mod 10

-we determine if l is odd or even By doing the operatio b=l mod 2

- if l is even (b=0) then we upgrade i1 ; i1=i1*10

we count the new N1 ; N1=N1+l*i1

Otherwise we upgrade i2; i2=i2*10

we count the new N2 ; N2=N2+l*i2

-we upgrade the value of i;i=i*10

.we devid N1 or N2 by 10 depending on the value of d

*if d=0 we devide N2 by 10

Otherwise we devide N1 by 10

.we display the values of N1 and N2

Algorithm:spliting_odd_and_even_digits

Variables N,N1,N2,i1,i2,l,d,b:integers

Begin

Write(‘please Input the number’)


Read(N)

N1 <- 0

N2 <- 0

L <- N mod 10

D <- L mod 2

If d=0 then

N1 <- l

Elese N2 <- l

End if

i1 <- 1

i2 <- 1

While N>=10 do

N <- N div 10

L <- N mod 10

B<- l mod 2

If b=0 then

Begin

i1 <- i1*10

N1=N1 + l*i1

End

Elese

Begin

i2 <- i2 *10

N2=N2+l*i2

End

End

If d=0 then
N2<-N2/10

Elese

N1<-N1/10

End if

Write(‘N1 is’,N1,’ and N2 is’,N2)

End.

You might also like