Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //mi prog 2//
- INCLUDE io.h
- cr EQU 0dH
- lf EQU 0aH
- data SEGMENT
- list DW 40 DUP(?)
- prompt1 DB 'Enter the maximum no of elements : ',0
- prompt2 DB cr,lf,'Enter the elements: ',cr,lf,0
- prompt3 DB cr,lf,'Total sum: '
- sum DW 2 DUP(?)
- DB cr,lf,cr,lf,0
- prompt4 DB cr,lf,'Average: '
- avg DW 2 DUP(?)
- DB cr,lf,cr,lf,0
- prompt5 DB cr,lf,'The elements greater than average are: ',0
- p DB ' '
- print DW 1 dup(?)
- DB 0
- string Dw 20 DUP(?)
- count DW ?
- data ENDS
- code SEGMENT
- ASSUME cs:code, ds:data
- start: mov ax, SEG data
- mov ds, ax
- mov Si, OFFSET list
- mov bx, 00
- output prompt1
- inputs string, 20
- atoi string
- mov count, ax
- mov cx, ax
- output prompt2
- again: inputs string, 20
- atoi string
- mov [SI], ax
- add bx, ax
- add SI, 2
- dec cx
- jnz again
- itoa sum, bx
- output prompt3
- mov ax,bx
- cwd
- div count
- itoa avg, ax
- output prompt4
- mov SI, OFFSET list
- mov bx, ax
- mov cx, count
- output prompt5
- again1: cmp [SI], bx
- jb again2
- mov ax, [si]
- itoa print, ax
- output p
- again2: add si, 2
- dec cx
- jnz again1
- quit: mov al, 00
- mov ah, 4cH
- int 21H
- code ENDS
- END start
Advertisement
Add Comment
Please, Sign In to add comment