Ok, had posted that last one before I realised there was a reply!!!!
Changing bit_array to codeword_array worked for a lot of them, down to 7 errors now.
code is
Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
int codeword_array[20];
int i=0;
int bit;
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++)
{
scanf("%d", &bit);
if (bit != 0 && bit !=1)
{
printf("All bits must be a 0 or a 1/n");
}
else
{
codeword_array[i] = bit;
}
if (codeword_array[0] + codeword_array[5] + codeword_array[10] == (0||2))
{
codeword_array[15] = 0;
}
else if (codeword_array[0] + codeword_array[5] + codeword_array[10] == (1||3))
{
codeword_array[15] = 1;
}
else
{
printf("Error\n");
}
system("pause");
return 0;
}
/*scanf( "%d", &bit1 );
if ( bit1 != (0 || 1))
{
printf( "All bits must be either 0 or 1\n" );
}
else
{
printf( "You entered %d", bit1);
}
and the remaining errors are
Code:
(14) : error C2143: syntax error : missing ';' before 'type'
(14) : error C2143: syntax error : missing ';' before 'type'
(14) : error C2143: syntax error : missing ')' before 'type'
(14) : error C2143: syntax error : missing ';' before 'type'
(14) : warning C4552: '<' : operator has no effect; expected operator with side-effect
(14) : error C2059: syntax error : ')'
(15) : error C2143: syntax error : missing ';' before '{'
(43) : warning C4013: 'system' undefined; assuming extern returning int
(94) : fatal error C1075: end of file found before the left brace '{' at 'c:\users\niall\documents\college\4th year\2nd semester\ee402\5bit parity code\5bit parity code\source.c(6)' was matched