Hi all,
1st time poster.
I have a fairly simple task that I need to carry out, however I am not terribly good at C programming, so bare with me!!!!
Basically I need to take in a string of 15 binary bits, from this input I will be adding bits 1,6,11 bits 2,7,12 bits 3,8,13 bits 4,9,14 and bits 5,10,15.
These will all give me parity which will either be a 0 or a 1. I then have to output the original 15 bits along with the 5 new bits, so my output will be 20 bits long.
I hope that all makes sense.......so far I have been trying to do it as such........
The thinking behind this is that if I use a 20 bit array, and start off filling the 1st 15 blocks, then do the parity check on them and with my answers fill the final 5.Code:#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
int codeword_array[20];
int i=0;
printf("Welcome to the 5-bit parity code calculator\nPlease enter the 1st bit of the 15 bit codeword now: \n");
for (int i>=0; i<16; i++)
{
int bit_array[i];
scanf("%d", bit_array[i])
if bit !=(0||1)
{
printf("All bits must be 0 or a 1");
}
codeword_array[i] = bit[i];
}
if (bit_array[0] + bit_array[5] + bit_array[10] = (0||2))
{
codeword_array[15] = 0;
}
else if (bit_array[0] + bit_array[5] + bit_array[10] = (1||3))
{
codeword_array[15] = 1;
}
else
{
printf("Error\n");
}
system("pause");
return 0;
}
However I am getting a good few errors on this.
Hope someone can help.
Regards,
Niall.

