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