Thread: Generate Possible combination of 6-bit Binary number

  1. #16
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Can you post your code? It will be easier to comment on that, rather than try to give hints while not giving too much away.

  2. #17
    Registered User
    Join Date
    Aug 2012
    Posts
    26
    Quote Originally Posted by Subsonics View Post
    Does it really matter how you represent your number(s) or even if you do? From what's said it does not seem that way..
    In short we have to print Truth Table of 6 bit binary digits as truth table covers all possible combinations.

  3. #18
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by Azeem View Post
    In short we have to print Truth Table of 6 bit binary digits as truth table covers all possible combinations.
    Exactly, so you will need no variables except the index variable in your for loop!

  4. #19
    Registered User
    Join Date
    Aug 2012
    Posts
    26
    Matticus

    Code:
    #include<stdio.h>int main(void)
    {
        int a,b,c,d,e,f,i;
        for(i=1; i<=64; i++)
        {
            for(a=0; a<=0; ++a)
            {
                printf("%d",a);
    
    
            }
            printf("\n");
    
    
        }
        return 0;
    }
    This program is for first column & i know it is incorrect
    Last edited by Azeem; 08-24-2012 at 10:38 AM.

  5. #20
    Registered User
    Join Date
    Aug 2012
    Posts
    26
    Quote Originally Posted by Subsonics View Post
    Exactly, so you will need no variables except the index variable in your for loop!
    What are index variables?

  6. #21
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Quote Originally Posted by Subsonics View Post
    Does it really matter how you represent your number(s) or even if you do? From what's said it does not seem that way..
    You've left out part of the description, the "nested for() loops" part. Matticus is using his knowledge of weird beginner assignments in assuming six nested loops (if that's what he's thinking of). I'm assuming that interpretation myself. In that case you need 6 index variables and each goes from 0 to 1.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  7. #22
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    The outer for loop should go from 0 to 64 so:

    for(i = 0; i < 64; i++)
    The inner loop would print 'i' as binary. If you do not know how to do that, then create a separate program to experiment with that. In this case it does not matter if it's printed from left or right since you are not interested in the actual values.

  8. #23
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by oogabooga View Post
    You've left out part of the description, the "nested for() loops" part. Matticus is using his knowledge of weird beginner assignments in assuming six nested loops (if that's what he's thinking of). I'm assuming that interpretation myself. In that case you need 6 index variables and each goes from 0 to 1.
    I did, but it does not mention that it has to be 6 nested loops. It could also be solved with 2 nested loops.

  9. #24
    Registered User
    Join Date
    Aug 2012
    Posts
    26
    Quote Originally Posted by Subsonics View Post
    The outer for loop should go from 0 to 64 so:



    The inner loop would print 'i' as binary. If you do not know how to do that, then create a separate program to experiment with that. In this case it does not matter if it's printed from left or right since you are not interested in the actual values.
    it is mandatory to use nested for() loop. I am not allowed to use any decimal to binary conversion.

  10. #25
    Registered User
    Join Date
    Aug 2012
    Posts
    26
    The output Should be like this:
    Generate Possible combination of 6-bit Binary number-output-jpg

  11. #26
    Registered User
    Join Date
    Aug 2012
    Posts
    26
    Quote Originally Posted by Matticus View Post
    Can you post your code? It will be easier to comment on that, rather than try to give hints while not giving too much away.
    Code:
    #include<stdio.h>
    int main(void)
    {
        int a,b,c,d,e,f,i;
        for(i=1; i<=64; i++)
        {
            for(a=0; a<=0; ++a)
            {
                printf("%d",a);
    
    
            }
            printf("\n");
    
    
        }
        return 0;
    }
    This program is for first column & i know it is incorrect

  12. #27
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by Azeem View Post
    What are index variables?
    'i' and 'a' in your case.

  13. #28
    Registered User
    Join Date
    Aug 2012
    Posts
    26
    Quote Originally Posted by Subsonics View Post
    'i' and 'a' in your case.
    ok got it

  14. #29
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I did, but it does not mention that it has to be 6 nested loops. It could also be solved with 2 nested loops.
    The question is whether it can be solved "any way," for whether there is a specific implementation that is expected. oogabooga and I are assuming the latter (which would require six nested loops).

    @OP: There are actually a lot of hints in these posts that might give you a more clear idea of what we're talking about.

  15. #30
    Registered User
    Join Date
    Aug 2012
    Posts
    26
    Quote Originally Posted by Matticus View Post
    The question is whether it can be solved "any way," for whether there is a specific implementation that is expected. oogabooga and I are assuming the latter (which would require six nested loops).

    @OP: There are actually a lot of hints in these posts that might give you a more clear idea of what we're talking about.
    use 6 nested loops to generate the output & my code is incomplete right now. I am not getting how to proceed further.
    Last edited by Azeem; 08-24-2012 at 10:55 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. generate number
    By cheeta in forum C Programming
    Replies: 9
    Last Post: 05-03-2010, 07:49 AM
  2. Replies: 8
    Last Post: 09-27-2008, 07:32 PM
  3. binary combination.
    By Moony in forum C Programming
    Replies: 1
    Last Post: 02-24-2008, 12:55 AM
  4. To generate bar code from a number
    By darkducke in forum C Programming
    Replies: 18
    Last Post: 01-16-2008, 06:33 AM
  5. generate a random number
    By waxydock in forum C++ Programming
    Replies: 5
    Last Post: 06-05-2005, 07:43 PM