Mix (C++ and Assembly) Program to Find Smallest Number from Given Numbers

#include<iostream.h>
#include<conio.h>
void main()
{
	short a[5],x,y,res;
	short i,j;
	y=999;

	cout<<"\n Enter 5 Numbers:";
	for(i=0;i<5;i++)
	{
		cin>>a[i];
	}

	asm{
		mov bx,y
	}

	//Finding smallest
	for(i=0;i<5;i++)
	{
		x=a[i];
		asm{
			mov ax,x
			mov bx,y
			cmp ax,bx
			jnb nxt
			mov bx,ax
			mov y,bx
		}
		nxt:
	}

	asm{
		mov res,bx;
	}

	cout<<"\n Smallest Element:"<<res;
	getch();
}

/* OUTPUT

 Enter 5 Numbers:15
20
10
8
24

 Smallest Element:8

*/

Leave a Reply

Your email address will not be published. Required fields are marked *