Monday, January 25, 2010

Left shift - Right Shift

#include< stdio.h >
int powerof2(int a)
{
int p=0;
for(int i=0;i p+=2;
return p;
}
main()
{
int n,shift,ln,rn;
printf("enter number and shifting number");
scanf("%d %d",&n,&shift);
ln=n*powerof2(shift);
rn=n/powerof2(shift);
printf("Left shift: %d", ln);
printf("Right shift: %d", rn);
}

0 comments:

Post a Comment