Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include io.h
- cr equ 0dh
- lf equ 0ah
- data segment
- prompt db'enter the number of elements:',0
- number db 8 dup(?)
- num db 8 dup(?)
- num1 dw ?
- num2 dw ?
- num_elem dw ?
- num_prompt db cr,lf,'enter the numbers',0
- number_arr dw 100 dup(?)
- elem db 8 dup(?)
- msg1 db cr,lf,'the array entered is:',cr,lf,0
- msg2 db cr,lf,'the number of even numbers is:'
- elem1 db 8 dup(?)
- msg3 db cr,lf,'the number of odd number is:'
- elem2 db 8 dup(?)
- data ends
- code segment
- assume cs:code,ds:data
- start: mov ax,seg data
- mov ds,ax
- output prompt
- inputs number,8
- atoi number
- cmp ax,0
- jg continue
- jmp quit
- continue:mov num_elem,ax
- mov si,0000h
- mov bx,num_elem
- output num_prompt
- while: inputs num,8
- atoi num
- mov number_arr[si],ax
- add si,2
- dec bx
- cmp bx,0
- jg while
- end_while:
- mov cx,num_elem
- output msg1
- mov si,0000h
- for1: itoa elem,number_arr[si]
- output elem
- add si,2
- loop for1
- mov cx,num_elem
- mov si,0000h
- mov bx,2
- for2: mov ax,number_arr[si]
- cwd
- idiv bx
- cmp dx,0
- jne down2
- inc num1
- add si,2
- loop for2
- jmp down3
- down2: inc num2
- add si,2
- loop for2
- down3: mov ax,num1
- itoa elem1,ax
- output msg2
- mov bx,num2
- itoa elem2,bx
- output msg3
- quit: mov al,0
- mov ah,4ch
- int 21h
- code ends
- end start
- enter the number of elements:5
- enter the numbers12
- 15
- 13
- 14
- 11
- the array entered is:
- 12 15 13 14 11
- the number of even numbers is: 2
- the number of odd number is: 3
Advertisement
Add Comment
Please, Sign In to add comment