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

Program

The document contains a C program that simulates a packet storage system with a specified bucket size. It allows the user to input the number of incoming packets and outgoing packets, managing the storage accordingly while handling overflow by dropping packets. The program outputs the current state of the storage after each operation until all inputs are processed.

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 DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Program

The document contains a C program that simulates a packet storage system with a specified bucket size. It allows the user to input the number of incoming packets and outgoing packets, managing the storage accordingly while handling overflow by dropping packets. The program outputs the current state of the storage after each operation until all inputs are processed.

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 DOCX, 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