-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.Vertical_Redundancy_Code.c
More file actions
64 lines (54 loc) · 1.56 KB
/
3.Vertical_Redundancy_Code.c
File metadata and controls
64 lines (54 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
int main()
{
int i, v, c[4];
char f[4][8];
for (i = 0; i < 4; i++)
{
printf("Enter the frame %d:\n", i + 1);
scanf(" %s", f[i]);
}
for (i = 0; i < 8; i++)
{
if (f[0][i] == '1') c[0]++;
if (f[1][i] == '1') c[1]++;
if (f[2][i] == '1') c[2]++;
if (f[3][i] == '1') c[3]++;
}
v = c[0] + c[1] + c[2] + c[3];
if (v % 2 == 0)
puts("There is No error in received Data frame at the Destination.");
else
{
for (i = 0; i < 4; i++)
printf("There is %s error in frame %d.\n", (c[i] % 2) ? "\b" : "no", i + 1);
}
return 0;
}
// Input/Output:-
// ------------
// case 1:
// -------
// Enter the frame 1:
// 10101010 /* Input */
// Enter the frame 2:
// 10000000 /* Input */
// Enter the frame 3:
// 00000001 /* Input */
// Enter the frame 4:
// 11111110 /* Input */
// There is no error in frame 1.
// There is error in frame 2.
// There is error in frame 3.
// There is error in frame 4.
// case 2:
// -------
// Enter the frame 1:
// 00000000 /* Input */
// Enter the frame 2:
// 10000001 /* Input */
// Enter the frame 3:
// 11111111 /* Input */
// Enter the frame 4:
// 11110000 /* Input */
// There is No error in received Data frame at the Destination.