diff --git a/Algorithms/Sliding window algorithm b/Algorithms/Sliding window algorithm new file mode 100644 index 0000000..b84845e --- /dev/null +++ b/Algorithms/Sliding window algorithm @@ -0,0 +1,36 @@ +#include + +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; +} diff --git a/Algorithms/eucledian.c b/Algorithms/eucledian.c new file mode 100644 index 0000000..129e3a5 --- /dev/null +++ b/Algorithms/eucledian.c @@ -0,0 +1,30 @@ + +// Euclidean Algorithm +#include + +// 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; +} diff --git a/contributors.md b/contributors.md index 249a928..3a80c73 100644 --- a/contributors.md +++ b/contributors.md @@ -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) \ No newline at end of file +24. [Rohit Sekar](https://github.com/rohitsekar1996)