Mix (C++ and Assembly) Program to Find Whether Number is Odd or Even

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,res;
cout<<"\n Enter a number";
cin>>a;
asm mov ax,a
asm mov bx,02h
asm div bx
asm mov res,dx
if(res==0)
{
cout<<"\n Even";
}
else
cout<<"\n Odd";
getch();
}


/* OUTPUT


 Enter a number15

 Odd


 Enter a number20                                                               
                                                                                
 Even                                                                           

*/

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.