Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Algorithms/Sliding window algorithm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include<stdio.h>

int main()
{
int w,i,f,frames[50];

printf("Enter window size: ");
scanf("%d",&w);

printf("\nEnter number of frames to transmit: ");
scanf("%d",&f);

printf("\nEnter %d frames: ",f);

for(i=1;i<=f;i++)
scanf("%d",&frames[i]);

printf("\nWith sliding window protocol the frames will be sent in the following manner (assuming no corruption of frames)\n\n");
printf("After sending %d frames at each stage sender waits for acknowledgement sent by the receiver\n\n",w);

for(i=1;i<=f;i++)
{
if(i%w==0)
{
printf("%d\n",frames[i]);
printf("Acknowledgement of above frames sent is received by sender\n\n");
}
else
printf("%d ",frames[i]);
}

if(f%w!=0)
printf("\nAcknowledgement of above frames sent is received by sender\n");

return 0;
}
30 changes: 30 additions & 0 deletions Algorithms/eucledian.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

// Euclidean Algorithm
#include <stdio.h>

// C function for extended Euclidean Algorithm
int gcdExtended(int a, int b, int *x, int *y)
{
// Base Case
if (a == 0)
{
*x = 0;
*y = 1;
return b;
}

int x1, y1; // To store results of recursive call
int gcd = gcdExtended(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;

return gcd;
}
int main()
{
int x, y;
int a = 35, b = 15;
int g = gcdExtended(a, b, &x, &y);
printf("gcd(%d, %d) = %d", a, b, g);
return 0;
}
2 changes: 1 addition & 1 deletion contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
21. [Ankit Bajaj](https://github.com/ankit10101)
22. [Medha Sharma](https://github.com/medhasharma)
23. [Pritish Thakkar](https://github.com/ma5terdrag0n)
23. [Your Name](https://github.com/yourprofile)
24. [Rohit Sekar](https://github.com/rohitsekar1996)