Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
October 19th, 2012, 06:17 AM
 Hunain Hafeez
Registered User

Join Date: Oct 2012
Posts: 2
Time spent in forums: 26 m 35 sec
Reputation 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
October 19th, 2012, 06:30 AM
 salem
Contributed User

Join Date: Jun 2005
Posts: 4,258
Time spent in forums: 2 Months 4 Weeks 1 Day 14 h 21 m 32 sec
Reputation Power: 1827
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

#3
October 19th, 2012, 07:12 AM
 Hunain Hafeez
Registered User

Join Date: Oct 2012
Posts: 2
Time spent in forums: 26 m 35 sec
Reputation 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;

}

```

#4
October 19th, 2012, 08:33 AM
 salem
Contributed User

Join Date: Jun 2005
Posts: 4,258
Time spent in forums: 2 Months 4 Weeks 1 Day 14 h 21 m 32 sec
Reputation Power: 1827
Quote:
 #include #include #include #include #include #include #include #include #include

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;

On most machines, this would be a 64-bit variable, and would thus solve any messy emulation.

 Viewing: Dev Shed Forums > Programming Languages > C Programming > Ounter of 6 bit and i need a counter of 48 bit