Program to divide an integer by 4 without using ‘/’ operator. One of the most efficient way to divide an integer by 4 is to use right shift operator (“>>”).
// CPP program to divide a number by 4 without using '/'
#include<iostream>
using namespace std;
int main()
{
int n = 4;
n = n >> 2;
cout << n;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int n = 4;
n = n >> 2;
cout << n;
return 0;
}
OUTPUT:
1
1