Algorithm:
Step 1:
Take input from the user(let a).
Step 2:
Use one for loop from 0 to (2^a)-1.
Step3:
In each iteration , convert each i(variable used in for loop of step 2) to binary.
Step4:
Convert the integer i to it's corresponding binary form.
Step5:
Convert binary to gray code(Already studied in Digital Logic Design Course rignt!!).
You can recall the concept of converting binary to gray code from the following link:
https://www.youtube.com/watch?v=IeWcv...
Step6:
Make sure ---The graycode form must have a number of bits.
If the graycode form consists lesser than a no. of bits , then add certain amount of 0s
in the front side to make make total no. of bits=a.
Step7:
Print that graycode representation.
(Note)
I have also converted the graycode representation to it's decimal form , although
according to the question, it is not required.
**
Code is given in the comment section.
Step 1:
Take input from the user(let a).
Step 2:
Use one for loop from 0 to (2^a)-1.
Step3:
In each iteration , convert each i(variable used in for loop of step 2) to binary.
Step4:
Convert the integer i to it's corresponding binary form.
Step5:
Convert binary to gray code(Already studied in Digital Logic Design Course rignt!!).
You can recall the concept of converting binary to gray code from the following link:
https://www.youtube.com/watch?v=IeWcv...
Step6:
Make sure ---The graycode form must have a number of bits.
If the graycode form consists lesser than a no. of bits , then add certain amount of 0s
in the front side to make make total no. of bits=a.
Step7:
Print that graycode representation.
(Note)
I have also converted the graycode representation to it's decimal form , although
according to the question, it is not required.
**
Code is given in the comment section.
Generate n-bit Gray Codes in simplest way (JAVA) video editing software free | |
Likes | Dislikes |
26 views views | 1.03K followers |
Science & Technology | Upload TimePublished on 1 Sep 2019 |
Không có nhận xét nào:
Đăng nhận xét