Given an amount of RAM (in megabytes) that is provided by the user, write a prog
ID: 3574130 • Letter: G
Question
Given an amount of RAM (in megabytes) that is provided by the user, write a program that utilizes the stack or queue concept where the program allocates space used by the applications listed above. Data Structure: Use a linked list structure. Bonus: Create an array data structure that runs parallel to the linked list structure. Actions: The program will continue to ask the user to select an application to run until they decide to quit the program. When the user decides to quit, the program will print all the current running items on the stack and the amount of RAM (in megabytes) currently available on the computer. If the computer doesn't have enough memory to run an application, applications arc removed from the stack or queue until enough memory is available to run the application. So. there will never be an instance where an application cannot be run.Explanation / Answer
#include #include #include #definr MINREQ 0*FFF struct Node { int data; struct Node *next; }*top = NULL; void push(char[],int); void pop(); void display(); void main() { int choice; unsigned int size; char value[50]; clrscr(); while(1){ printf(" ****** MENU ****** "); printf("1. Push 2. Pop 3. Exit "); printf("Enter your choice: "); scanf("%d",&choice); switch(choice){ case 1: printf("Enter the application to be insert: "); scanf("%s", &value); printf("Enter the memory size of application: "); scanf("%x", & size); push(value,size); break; case 2: pop(); break; case 3: display(); break; default: printf(" Wrong selection!!! Please try again!!! "); } } } void push(char value[50],unsigned int size) { struct Node *newNode; if((size>>=1)data = value; if(top == NULL) newNode->next = NULL; else newNode->next = top; top = newNode; printf(" Insertion is Success!!! "); } } void pop() { if(top == NULL) printf(" Stack is Empty!!! "); else{ struct Node *temp = top; printf(" Deleted element: %s", temp->data); top = temp->next; free(temp); } } void display() { if(top == NULL) printf(" Stack is Empty!!! "); else{ printf(" Applicaion on stack !!! "); struct Node *temp = top; while(temp->next != NULL){ printf("%s--->",temp->data); temp = temp -> next; } printf("%d--->NULL",temp->data); printf(" Amount of RAM currently available on computer : ",statex.ullTotalPhys/1024); } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.