#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],m[10],q[10],i,j,c=0,b[10];
clrscr();
printf("\n Enter the value of multiplicant(m) : ");
for(i=4;i>=1;i--)
{
scanf("%d",&m[i]);
a[i]=0;
}
printf("\n Enter the value of multiplier (q) : ");
for(i=4;i>=1;i--)
scanf("%d",&q[i]);
for(j=1;j<=4;j++)
{
if(q[1]==1)
{
for(i=1;i<=4;i++)
{
b[i]=((!m[i]&&!a[i]&&c)||(!m[i]&&a[i]&&!c)
||(m[i]&&a[i]&&c)||(m[i]&&!a[i]&&!c));
c=((m[i]&&a[i])||(a[i]&&c)||(m[i]&&c));
a[i]=b[i];
}
}
for(i=1;i<=3;i++)
q[i]=q[i+1];
q[4]=a[1];
for(i=1;i<=3;i++)
a[i]=a[i+1];
a[4]=c;
c=0;
}
printf("\n\n Solution for (m*q) : ");
for(i=4;i>=1;i--)
printf("%d",a[i]);
for(i=4;i>=1;i--)
printf("%d",q[i]);
getch();
}
/* OUTPUT
Enter the value of multiplicant(m) : 1 0 0 1
Enter the value of multiplier (q) : 0 1 0 0
Solution for (m*q) : 00100100
*/
No comments:
Post a Comment