#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,ch,n;
unsigned int c,d;
clrscr();
while(1)
{
printf("\n1:right shift");
printf("\n2:left shift");
printf("\n3:ones complement");
printf("\n4:exit");
printf("\nenter the choice");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("\nenter the number:");
scanf("%d",&a);
printf("\nenter the nmuber where you want to shift:");
scanf("%d",&n);
b=a>>n;
printf("\nresult of right shift is:%d",b);
break;
case 2:printf("\nenter the number:");
scanf("%d",&a);
printf("enter the nmuber where you want to shift:");
scanf("%d",&n);
b=a<<n;
printf("\nresult of right shift is :%d",b);
break;
case 3:printf("\nenter the hexadecimalnumber:");
scanf("%x",&c);
d=~c;
printf("the ones complement of number is :%x",d);
break;
case 4:exit();
}
getch();
}
}
/*
1:right shift
2:left shift
3:ones complement
4:exit
enter the choice1
enter the number:64
enter the nmuber where you want to shift:2
result of right shift is:16
1:right shift
2:left shift
3:ones complement
4:exit
enter the choice2
enter the number:45
enter the nmuber where you want to shift:2
result of right shift is :180
1:right shift
2:left shift
3:ones complement
4:exit
enter the choice3
enter the hexadecimalnumber:07ff
the ones complement of number is :f800
1:right shift
2:left shift
3:ones complement
4:exit
enter the choice4
*/
No comments:
Post a Comment