Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Explain step by step the next c++ source code for the problem shownbelow... The

ID: 3613697 • Letter: E

Question

Explain step by step the next c++ source code for the problem shownbelow...

The problem is:

Please write a function “showbits”.
     1.     
The task of showbits is to display the binaryrepresentation of any integer.( Print
             binary equivalent of integers)

     2.     
Any division or remainder operator is notallowed.
     3.     
You can use bitwise operator in this problem.

The source code is:

#include <iostream>
using namespace std;
int main()
{int i;
unsigned int num,mask=0x80000000,bit;
cout<<"Enter a number: ";
cin>>num;
cout<<num<<" in binary is: ";
for(i=0;i<32;i++)
    {bit=num&mask;
     if(bit==0)
        cout<<"0";
     else
        cout<<"1";
     mask=mask>>1;
     }cout<<endl;
system("pause");
return 0;
}

Explanation / Answer

please rate - thanks #include using namespace std; int main() {int i; unsigned intnum,mask=0x80000000,bit;                                          //create a mask with 1 bit set coutnum; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote