The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Ounter of 6 bit and i need a counter of 48 bit
Discuss Ounter of 6 bit and i need a counter of 48 bit in the C Programming forum on Dev Shed. Ounter of 6 bit and i need a counter of 48 bit C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 19th, 2012, 05:17 AM
|
|
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;
}
|

October 19th, 2012, 05:30 AM
|
 |
Contributed User
|
|
|
|
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;
}
|

October 19th, 2012, 06:12 AM
|
|
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;
}
|

October 19th, 2012, 07:33 AM
|
 |
Contributed User
|
|
|
|
Quote:
#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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|