Program
Program
#include<stdio.h>
void main()
{
int in,out,bsize,n,store=0;
printf("\nEnter the no. of inputs:\t");
scanf("%d",&n);
printf("\nEnter the outgoing packets:\t");
scanf("%d",&out);
printf("\nEnter the bucket size:\t");
scanf("%d",&bsize);
while(n!=0)
{
printf("\n\nEnter the incoming packets:\t");
scanf("%d",&in);
if(in<=(bsize-store))
{
store=store+in;
printf("\n%d out of %d",store,bsize);
}
else
{
printf("\nCannot accomodate! Dropped the packet");
printf("\n%d out of %d",store,bsize);
}
if(store<out)
{
printf("\noutgoing %d packets! 0 out of %d",store,bsize);
store=0;
n--;
}
else
{
store=store-out;
printf("\noutgoing %d packets! %d out of %d",out,store,bsize);
n--;
}
}
printf("\n");
OUTPUT