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

Lbu 1

The document contains a C program that simulates a packet handling system with a defined bucket size. It prompts the user for the number of incoming packets, outgoing packets, and the bucket size, and processes the packets accordingly, either storing them or dropping them if they exceed the bucket capacity. The program also manages the outgoing packets based on the stored packets and provides feedback on the current state 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)
8 views2 pages

Lbu 1

The document contains a C program that simulates a packet handling system with a defined bucket size. It prompts the user for the number of incoming packets, outgoing packets, and the bucket size, and processes the packets accordingly, either storing them or dropping them if they exceed the bucket capacity. The program also manages the outgoing packets based on the stored packets and provides feedback on the current state 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