#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Ounter of 6 bit and i need a counter of 48 bit


    this code is working for a counter of 6 bit and i need a counter of 48 bit ... if u have time kindly try it..... i try alot but not succeed

    #include<stdio.h>
    #include<stdlib.h>
    #include<float.h>
    #include<math.h>
    #include <time.h>
    #include <cstdlib>
    #include <iostream>
    #include<stdint.h>
    #include<conio.h>

    int main()
    {

    int a[64][6];
    int i,j,k,d,c,n;
    for(k=0;k<64;k++) //6 digit binary so 2^6 =64 is no: of combinations
    {
    for(j=0;j<6;j++)
    {
    a[k][j]=0;
    }
    }
    for(i=0;i<64;i++)
    {
    n=i;
    for(j=5;j>=0;j--)
    {
    while(n!=0)
    {
    a[i][j]=n%2;
    j--;
    n=n/2;
    }
    }
    }
    for(k=0;k<64;k++)
    {
    for(j=0;j<6;j++)
    {
    printf("%d",a[k][j]);
    }
    printf(" .................%d\n",k);
    }
    //printf("\n **** KHATAM SHo ****\n");
    getch();
    return 0;

    }
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    Edit your post, and put [code][/code] tags around the code.

    It should look like this when you're done.
    Code:
    #include <stdio.h>
    int main ( ) {
        // code code code
        return 0;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<float.h>
    #include<math.h>
    #include <time.h>
    #include <cstdlib>
    #include <iostream>
    #include<stdint.h>
    #include<conio.h>
    
    int main()
    {
    
     int a[64][6];
     int  i,j,k,d,c,n;
    for(k=0;k<64;k++) //6 digit binary so 2^6 =64 is no: of combinations 
    {
        for(j=0;j<6;j++)
        {
            a[k][j]=0;
        }
    }
    for(i=0;i<64;i++)
    {
        n=i;
        for(j=5;j>=0;j--)
        {
            while(n!=0)
            {
                a[i][j]=n%2;
                j--;    
                n=n/2;      
            }
        }
    }
    for(k=0;k<64;k++)
    {
        for(j=0;j<6;j++)
        {
            printf("%d",a[k][j]);
        }
        printf(" .................%d\n",k);
    }
    //printf("\n **** KHATAM SHo ****\n");
        getch();
        return 0;
        
    }
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    #include<stdio.h>
    #include<stdlib.h>
    #include<float.h>
    #include<math.h>
    #include <time.h>
    #include <cstdlib>
    #include <iostream>
    #include<stdint.h>
    #include<conio.h>
    First, decide whether you're writing C or C++.
    Including a whole mess of header files from all over the place doesn't help.

    > int a[64][6];
    > int i,j,k,d,c,n;
    Pick meaningful variable names.
    Aside from i,j for loop variables, everything else should have a more descriptive name.

    Also, how does 64 and 6 relate to your requirement for 48 bits?

    Which compiler are you using?
    I note from your use of <iostream> that it seems to be something reasonably modern.

    Perhaps you could try to see if
    unsigned long long var;
    is accepted by your compiler.

    On most machines, this would be a 64-bit variable, and would thus solve any messy emulation.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo