00:01
In this question here, we have to make a c+ + code.
00:05
So here, code is hutch include iostream hutch include bits std c+ + .h so using namespace std int main, so here, bracket open, count this program, this program converts an integer, an integer to binary, to binary and hex.
01:31
So here, count enter an integer.
01:48
Now here we have to enter an integer, that is int n.
01:54
Now take value of n from user, so it is cin less greater than greater than n.
02:06
Now make two strings binary and hex to store the binary and hexadecimal representation of n.
02:13
So string binary is equals to and string hex is equals to.
02:35
Now make i as 0, so int i equals to 0.
02:45
So now as we want answer till 8 bits, to run a loop till i less than 8.
02:53
So for this is, while i is less than 8, bracket open, if the ith bit in the number set or 1, then add 1 to its binary representation.
03:15
If n and 1 less than i, then binary plus equals to 1 and if ith bit in the number is unset or 0, then add 0 to its binary representation.
03:38
Else, binary plus equals to 0 and i plus plus, bracket close.
03:54
Now reverse the string binary, so reverse binary begin, binary end, binary dot end.
04:18
Here i equals to 0.
04:21
Now run the loop till n is not 0.
04:25
So for this is, while n is equals to 0, bracket open, then temporary variable to store remainder int temp equals to 0.
04:43
Now storing remainder in temp variable is temp equals to n percentage 16 and divided by 16...