Thursday, June 25, 2020

Left Shift and Right Shift Formula

#include <bits/stdc++.h>

using namespace std;

int main(){

    int a, x;
    while(scanf("%d %d", &a, &x)){
        int left = a*pow(2,x);
        int right = a/pow(2,x);

        printf("Left Shift is: %d and Right Shift is: %d\n", left, right);
    }

    return 0;
}

No comments:

Post a Comment