#include "stdio.h"
#include "string.h"
void main(){
char bin[100],ans[100];
int shift;
printf("Enter Binary Number : ");
scanf("%s",bin);
printf("Enter Shift Number : ");
scanf("%d",&shift);
for (int i = strlen(bin)-shift,j=0; i < bin[i]!='\0'; i++,j++)
{
ans[j]=bin[i];
}
for (int i = 0; i<strlen(bin)-shift; i++)
{
ans[i+shift]=bin[i];
ans[i+shift+1]='\0';
}
printf("Right shift binary is %s",ans);
}
#include "stdio.h"
#include "string.h"
void main(){
char bin[100],ans[100];
int shift;
printf("Enter Binary Number : ");
scanf("%s",bin);
printf("Enter Shift Number : ");
scanf("%d",&shift);
for (int i = 0; i<strlen(bin)-shift; i++)
{
ans[i]=bin[i+shift];
ans[i+1]='\0';
}
for (int i = strlen(bin)-shift,j=0; i < bin[i]!='\0'; i++,j++)
{
ans[i]=bin[j];
ans[i+1]='\0';
}
printf("Right shift binary is %s",ans);
}
0 Comments