A C Program to learn the use of shift left and shift right operator.


#include<stdio.h>
#include<conio.h>
void main()
{
int n,a,x,y;

clrscr;
printf("Enter value of n:");
scanf("%d",&n);
a=n;
x=n<<1     /*Multiply n by 2*/
y=a>>1     /*Divide n by 2*/
printf("Value of x:%d",x);
printf("Value of y:%d",y);
getch();
}

Comments