Answer:
Check the explanation
Explanation:
#include<stdio.h>
main()
{ int k=1,p,l,i;
int p2[8],p1[8];
for(i=0;i<8;i++){
p1[i]=0;
p2[i]=0;
}
while(k==1)
{
printf("enter the pin inputs from p2.3-p2.5:");
scanf("%d%d%d",&p2[3],&p2[4],&p2[5]);
printf("Press Logic 0 for on and 1 for off on switch port p2.0\n");
scanf("%d",&l);
p1[3]=p2[3];
p1[4]=p2[4];
p1[5]=p2[5];
if(l==0)
{p=1;
for(i=0;i<8;i++)
printf("p1.%d : %d\n",i,p2[i]);
printf("\n press either 1 to continue or 0 to stop :");
scanf("%d",&p);
printf("\n");
while(p==1)
{ printf("enter the pin inputs from p2.3-p2.5:");
scanf("%d%d%d",&p2[3],&p2[4],&p2[5]);
p1[3]=p2[3];
p1[4]=p2[4];
p1[5]=p2[5];
for(i=0;i<8;i++)
printf("p1.%d : %d\n",i,p2[i]);
printf("\n press either 1 to continue or 0 to stop :");
scanf("%d",&p);
printf("\n");
}
}
else
{
printf("After Rotation of pattern :\n");
for(i=0;i<8;i++)
{ if(p2[i]==0)
printf("p1.%d : 1\n",i);
else
printf("p1.%d : 0\n",i);
}
}
printf("press 0 for on and 1 for off on switch port p2.1 :\n");
scanf("%d",&l);
if(l==0)
{ printf("\nLeft Rotation of pattern from read mode :\n");
printf("p1.0 : %d\n",p1[0]);
printf("p1.1 : %d\n",p1[5]);
printf("p1.2 : %d\n",p1[6]);
printf("p1.3 : %d\n",p1[3]);
printf("p1.4 : %d\n",p1[2]);
printf("p1.5 : %d\n",p1[1]);
printf("p1.7 : %d\n",p1[6]);
printf("p1.7 : %d\n",p1[7]);
}
else
{printf("\nRight rotation of pattern from read mode: \n");
printf("p1.0 : %d\n",p1[0]);
printf("p1.1 : %d\n",p1[1]);
printf("p1.2 : %d\n",p1[2]);
printf("p1.3 : %d\n",p1[7]);
printf("p1.4 : %d\n",p1[6]);
printf("p1.5 : %d\n",p1[5]);
printf("p1.7 : %d\n",p1[4]);
printf("p1.7 : %d\n",p1[3]);
}
printf("press 0 for on and 1 for off on switch port p2.2 :\n");
scanf("%d",&l);
if(l==0)
printf("Make Rotation fast\n");
else
printf("Make Rotation slow\n");
printf("Enter 1 to continue or 0 to exit:");
scanf("%d",&k);
printf("\n");
}
}