Write a program to right shift
Example 1:
Input: num=17
Output:8
Approach:
Java
public class RightShift {public static void main(String[] args) {int num = 17;// right shift a numberint right = num >> 1;System.out.println(right);}}
C++
#include <bits/stdc++.h>using namespace std;int main(){int num=17;//right shift a numberint right=num>>1;cout<<right<<"\n";return 0;}
No comments:
Post a Comment