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

Bankers 2

The document is a C program that implements a resource allocation system using matrices to manage available resources, allocation, and maximum needs for processes. It provides a menu-driven interface for users to accept available resources, display allocation and maximum matrices, display the need matrix, and show available resources. The program continues to run until the user chooses to exit.

Uploaded by

anishmaurya2004
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)
11 views2 pages

Bankers 2

The document is a C program that implements a resource allocation system using matrices to manage available resources, allocation, and maximum needs for processes. It provides a menu-driven interface for users to accept available resources, display allocation and maximum matrices, display the need matrix, and show available resources. The program continues to run until the user chooses to exit.

Uploaded by

anishmaurya2004
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

include<stdio.

h>
#include<stdlib.h>
#define P 5
#define R 3
void acceptAvailable(int available[]){
int i;
for(i=0;i<R;i++){
scanf("%d",&available[i]);
}
}
void displayAvailable(int available[]){
int i;
for(i=0;i<R;i++){
printf("%d\t",available[i]);
}
printf("\n");
}
void displayNeedMatrix(int allocation[P][R],int max[P][R]){
int need[P][R],i,j;
for(i=0;i<P;i++){
for(j=0;j<R;j++){
need[i][j]=max[i][j]-allocation[i][j];
}
}
printf("\nNeed Matrix:\n");
for(i=0;i<P;i++){
for(j=0;j<R;j++){
printf("%d\t",need[i][j]);
}
printf("\n");
}
}
void displayAllocationMax(int allocation[P][R],int max[P][R]){
int i,j;
printf("\nAllocation Matrix:\n");
for(i=0;i<P;i++){
for(j=0;j<R;j++){
printf("%d\t",allocation[i][j]);
}
printf("\n");
}
printf("\nMax Matrix:\n");
for(i=0;i<P;i++){
for(j=0;j<R;j++){
printf("%d\t",max[i][j]);
}
printf("\n");
}
}
int main(){
int allocation[P][R]={
{2,3,2},
{4,0,0},
{5,0,4},
{4,3,3},
{2,2,4} };
int max[P][R]={
{9,7,5},
{5,2,2},
{1,0,4},
{4,4,4},
{6,5,5}
};
int available[R]={3,3,2};
int choice;
do{
printf("\nMenu:\n");
printf("1. Accept Available\n");
printf("2. Display Allocation and Max \n");
printf("3. Display Need Matrix\n");
printf("4. Display Available\n");
printf("5. Exit\n");
printf("Enter your choice:");
scanf("%d",&choice);
switch(choice){
case 1:
acceptAvailable(available);
break;
case 2:
displayAllocationMax(allocation,max);
break;
case 3:
displayNeedMatrix(allocation,max);
break;
case 4:
displayAvailable(available);
break;
case 5:
printf("\nExiting the program\n");
break;
default:
printf("\nInvalid choice\n");
}
}while(choice!=5);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy