0% found this document useful (0 votes)
3 views2 pages

Program

The provided C program simulates a packet handling system where users can input the number of incoming packets and the outgoing packets while considering a defined bucket size. It checks if incoming packets can be accommodated within the bucket size and manages the outgoing packets accordingly. If the incoming packets exceed the available space, they are dropped, and the program outputs the current state of the bucket after each operation.

Uploaded by

foreverbo089
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Program

The provided C program simulates a packet handling system where users can input the number of incoming packets and the outgoing packets while considering a defined bucket size. It checks if incoming packets can be accommodated within the bucket size and manages the outgoing packets accordingly. If the incoming packets exceed the available space, they are dropped, and the program outputs the current state of the bucket after each operation.

Uploaded by

foreverbo089
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like