1) Find the sum of digits: #!/bin/bash number=$1sum=0 while [ $number -gt 0 ]do digit=$(( $number % 10 )) sum=$(( $sum + $digit )) number=$(( $number / 10 ))done echo “Sum of digits: $sum” 2) Find the average of numbers: #!/bin/bash sum=0count=0 for num in “$@”do sum=$(( $sum + $num )) count=$(( $count + 1Continue reading “Linux”
Category Archives: Uncategorized
Code
1) Program to find average of 3 numbers: .MODEL SMALL.DATA NUM1 DB 10 NUM2 DB 20 NUM3 DB 30 AVG DB ?.CODEMAIN PROC MOV AX, @DATA MOV DS, AX MOV AL, NUM1 ADD AL, NUM2 ADD AL, NUM3 MOV BL, 3 DIV BL ; AX = AX / 3 MOV AVG, AL MOV AH, 4CH Continue reading “Code”