Week 1a : Implement the data link layer farming methods such as
a. Bit stuffing. Problem Statement1: 1. Implement the data link layer farming method Bit stuffing to add 0 to each set of 4 ones in given string 011110 Problem Statement2: 2. Implement the data link layer farming method Bit stuffing to add !"#hite space$ to each set of % ones in given string 0111110 Problem Statement3: 3. Implement the data link layer farming method Bit stuffing to add & to each set of ' ones in given string 01111110 Problem Statement4: 4. Implement the data link layer farming method Bit stuffing to add ( to each set of ' ones in given string 01111110 Problem Statement4: 5. Implement the data link layer farming method Bit stuffing to add ) to each set of * ones in given string 011111110 1: +o the given ,its add the string 011110 to ,oth the starting and the end of the string a. +o add 0 to each set of 4 ones i.e. after every five consecutive 1-s appear a .ero /. +o the given ,its add the string 011110 to ,oth the starting and the end of the string a. +o add 0 to each set of 4 ones i.e. after every five consecutive 1-s appear a .ero 0include 1stdio.h1 0include 1conio.h1 int main"$ 2 int i304count305 char a610075 clrscr"$5 printf"1enter the ,its : 1$5 scanf"18s14a$5 printf"19n:fter ,it stuffing 9n1$5 printf"10111101$5 for"i305a6i75 i;;$ 2 if"a6i733<1<$ count;;5 else count305 printf"18c14a6i7$5 if"count334$ 2 printf"101$5 count305 = = printf"101111101$5 getch"$5 return 15 = Output: >. +o the given ,its add the string 01111110 to ,oth the starting and the end of the string a. +o add 0 to each set of % ones i.e. after every five consecutive 1-s appear a .ero Program: 0include 1stdio.h1 0include 1conio.h1 int main"$ 2 int i304count305 char a610075 printf"1enter the ,its : 1$5 scanf"18s14a$5
for"i305a6i75 i;;$ 2 if"a6i733<1<$ count;;5 else count305 printf"18c14a6i7$5 if"count33%$ 2 printf"101$5 count305 = = printf"1011111101$5 getch"$5 return 15 = 4. +o the given ,its add the string 011111110 to ,oth the starting and the end of the string a. +o add 0 to each set of ' ones i.e. after every five consecutive 1-s appear a .ero Program: 0include 1stdio.h1 0include 1conio.h1 int main"$ 2 int i304count305 char a610075 printf"1enter the ,its : 1$5 scanf"18s14a$5
for"i305a6i75 i;;$ 2 if"a6i733<1<$ count;;5 else count305 printf"18c14a6i7$5 if"count33'$ 2 printf"101$5 count305 = = printf"10111111101$5 getch"$5 return 15 Output: %. +o the given ,its add the string 0111111110 to ,oth the starting and the end of the string a. +o add 0 to each set of * ones i.e. after every five consecutive 1-s appear a .ero Program: 0include 1stdio.h1 0include 1conio.h1 int main"$ 2 int i304count305 char a610075 printf"1enter the ,its : 1$5 scanf"18s14a$5
for"i305a6i75 i;;$ 2 if"a6i733<1<$ count;;5 else count305 printf"18c14a6i7$5 if"count33*$ 2 printf"101$5 count305 = = printf"101111111101$5 getch"$5 return 15 Output: '. +o the given ,its add the string 01111111110 to ,oth the starting and the end of the string a. +o add 0 to each set of ? ones i.e. after every five consecutive 1-s appear a .ero 0include 1stdio.h1 0include 1conio.h1 int main"$ 2 int i304count305 char a610075 clrscr"$5 printf"1enter the ,its : 1$5 scanf"18s14a$5
printf"19n:fter ,it stuffing 9n1$5 printf"101111111101$5 for"i305a6i75 i;;$ 2 if"a6i733<1<$ count;;5 else count305 printf"18c14a6i7$5 if"count33?$ 2 printf"101$5 count305 = = printf"1011111111101$5 getch"$5 return 15 = *. +o the given ,its add the string 011111111110 to ,oth the starting and the end of the string. +o add 0 to each set of @ ones i.e. after every five consecutive 1-s appear a .ero Arogram: 0include 1stdio.h1 0include 1conio.h1 int main"$ 2 int i304count305 char a610075 clrscr"$5 printf"1enter the ,its : 1$5 scanf"18s14a$5
printf"19n:fter ,it stuffing 9n1$5 printf"1011111111101$5 for"i305a6i75 i;;$ 2 if"a6i733<1<$ count;;5 else count305 printf"18c14a6i7$5 if"count33?$ 2 printf"101$5 count305 = = printf"10111111111101$5 getch"$5 return 15 = Output: ?. +o the given ,its add the string 011111111110 to ,oth the starting and the end of the string. +o add 0 to each set of 10 ones i.e. after every five consecutive 1-s appear a .ero Arogram: 0include 1stdio.h1 0include 1conio.h1 int main"$ 2 int i304count305 char a610075 clrscr"$5 printf"1enter the ,its : 1$5 scanf"18s14a$5
printf"19n:fter ,it stuffing 9n1$5 printf"1011111111101$5 for"i305a6i75 i;;$ 2 if"a6i733<1<$ count;;5 else count305 printf"18c14a6i7$5 if"count3310$ 2 printf"101$5 count305 = = printf"101111111111101$5 getch"$5 return 15 = Butput: 9. C program to convert a ec!mal number to !t" e#u!valent $!t" %ormat. Program 0include Cstdio.hD 0include Cconio.hD void main"$ 2 unsigned long dec5 int a6/%74c304i5 clrscr"$5 printf"19nEF+EG : HEIIJ:K FLJBEG: 1$5 scanf"18lu14&dec$5 printf"19n8lu IF BI+M NBGJ:+: 14dec$5 #hile"decD0$ 2 a6c73dec8/5 dec3decO/5 c;;5 = for"i3cP15iD305iPP$ printf"18d14a6i7$5 getch"$5 = Output Enter a decimal num,er 4 4 in ,it format : 100 1&. Searc' a ke( number w!t'!n n g!ven number" u"!ng po!nter" Program 0include Cstdio.hD 0include Cconio.hD 0include Calloc.hD void main"$ 2 int n4Qp4i4num4flag305 clrscr"$5 printf"19nRBW J:FS FLJBEG: 1$5 scanf"18d14&n$5 p3"int Q$ malloc"nQ/$5 if"p33FLKK$ 2 printf"19nJEJBGS :KKBI:+IBF LFMLIIEMMNLK1$5 eTit"$5 = for"i305iCn5i;;$ 2 printf"19nEF+EG FLJBEG 8d: 14i;1$5 scanf"18d14p;i$5 = printf"19nEF+EG : FLJBEG +B ME:GIR: 1$5 scanf"18d14&num$5 for"i305iCn5i;;$ 2 if"num33Q"p;i$$ flag315 = if"flag331$ printf"19n+RE FLJBEG 8d IM NBLFH14num$5 else printf"19n+RE FLJBEG 8d HBEM FB+ EUIM+14num$5 getch"$5 = Butput: 11. C program %or 'e)aec!mal to $!t" conver"!on Program 0includeCstdio.hD 0define J:U 1000 int main"$2 char ,inaryFum,er6J:U74heTaHecimal6J:U75 long int i305 printf"1Enter any heTadecimal num,er: 1$5 scanf"18s14heTaHecimal$5 printf"19nEVuivalent ,its value: 1$5 #hile"heTaHecimal6i7$2 s#itch"heTaHecimal6i7$2 case <0<: printf"100001$5 ,reak5 case <1<: printf"100011$5 ,reak5 case </<: printf"100101$5 ,reak5 case <><: printf"100111$5 ,reak5 case <4<: printf"101001$5 ,reak5 case <%<: printf"101011$5 ,reak5 case <'<: printf"101101$5 ,reak5 case <*<: printf"101111$5 ,reak5 case <?<: printf"110001$5 ,reak5 case <@<: printf"110011$5 ,reak5 case <:<: printf"110101$5 ,reak5 case <B<: printf"110111$5 ,reak5 case <I<: printf"111001$5 ,reak5 case <H<: printf"111011$5 ,reak5 case <E<: printf"111101$5 ,reak5 case <N<: printf"111111$5 ,reak5 case <a<: printf"110101$5 ,reak5 case <,<: printf"110111$5 ,reak5 case <c<: printf"111001$5 ,reak5 case <d<: printf"111011$5 ,reak5 case <e<: printf"111101$5 ,reak5 case <f<: printf"111111$5 ,reak5 default: printf"19nInvalid heTadecimal digit 8c 14heTaHecimal6i7$5 return 05 = i;;5 = return 05 getch"$5 = Output: Week I,: Implement the data link layer framing methods such as character stuffing. C program to insert substring into a string at beging 0include Cstdio.hD 0include Cstring.hD 0include Cstdli,.hD