Input: Enter string : a s d l e f g h Enter position: 8 invalid position Enter again 3 Enter the character k Output: Frame after stuffing is: d l e s t x a s d l e k d l e d le e f g h d l e e t x
Computer Networks
KITS ENGG COLLEGE Page No:
AIM:- Implement the data link layer framing methods such as Bit Stuffing. PROGRAM: #include<stdio.h> #include<conio.h> #include<string.h> void main() { int n,i,j,c,count,a[20],b[30]; clrscr(); printf(enter the frame length); scanf(%d,&n); printf(enter input frame is 1s,0s only); for(i=0;i<n;i++) scanf(%d,&a*i+); i=0; count=1; j=0; while(i<n) { If(a[i]==1) b[j]=a[i]; for(k=i+1;a[k]==1&&k<n&&count<5;k++) Computer Networks
Output: Enter frame length:10 Enter input frame (0s,1s) 1010111111 After stuffing the frame:1010111111
Computer Networks
KITS ENGG COLLEGE Page No:
AIM:- To implement dijkstras algorithm to compute the shortest path. PROGRAM:- #include<stdio.h> main() { char ch='y',sp[10],nb[10]; int ds[10],j=0,k,sm,i,n; clrscr(); printf("enter the source node:"); sp[0]=getche(); j++; do { printf("\nhow many neighbours:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the neighbour name:"); nb[i]=getche(); printf("\n enter distance:"); scanf("%d",&ds[i]); } sm=ds[0]; Computer Networks
KITS ENGG COLLEGE Page No:
for(i=1;i<n;i++) { if(sm>ds[i]) { sm=ds[i];k=i; } } sp[j]=nb[k]; j++; sp[j]='\0'; printf("\n shortest path is:"); for(i=0;sp[i]!='\0';i++) printf("%c",sp[i]); printf("\n do u want more neighbours?y/n"); ch=getche(); }while(ch=='y'); getch(); }
Computer Networks
KITS ENGG COLLEGE Page No:
OUTPUT:- enter source node:A enter how many neighbours:4 enter neighbor name:B enter distance:2 enter neighbor name:C enter distance:3 enter neighbor name:D enter distance:4 enter neighbor name:E enter distance:1 shortrest path is:AE do you want more neighbours?y/n:n