0% found this document useful (0 votes)
58 views3 pages

ST 2

This C program opens a text file containing a binary string, counts the number of 1s in the string, determines if the parity is even or odd, and prints whether the data is accepted or rejected based on the parity check. It then prints the received data string.

Uploaded by

Bruce Arnold
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views3 pages

ST 2

This C program opens a text file containing a binary string, counts the number of 1s in the string, determines if the parity is even or odd, and prints whether the data is accepted or rejected based on the parity check. It then prints the received data string.

Uploaded by

Bruce Arnold
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<stdio.

h>

#include<conio.h>

#include<string.h>

void main()

int i, n,;

char output[20];

FILE *out;

clrscr();

out=fopen(data_parity.txt, r);

fscanf(out, %s, output);

n = strlen(output);

for(i=0; i<n; i++)

if(output[i]==1)

one++;

if(one%2==0)

printf(Received Data has Even Parity\n);

printf(Data Accepted\n);

else

printf(Received Data has Odd Parity\n);

printf(Data Rejected\n);

printf(Received Data: );

for(i=0;i<n-1; i++)

printf(%c, output[i];

fclose(out);

getch();

You might also like