

























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























































#include<iostream.h> #include<conio.h> int main() { intArr[ 100 ],n,temp; cout<<"Enter number of elements you want to insert "; cin>>n; for(inti= 0 ;i<n;i++) { cout<<"Enter element "<<i+ 1 <<":"; cin>>Arr[i]; } temp=Arr[ 0 ]; Arr[ 0 ]=Arr[n- 1 ]; Arr[n- 1 ]=temp; cout<<"\nArray after swapping"<<endl; for(i= 0 ;i<n;i++) cout<<Arr[i]<<" "; getch(); return 0 ; }
#include
Introduce int variables x, y, z and int* pointer variables p, q, r. Set x, y, z to three distinct values. Set p, q, r to the addresses of x, y, z respectively.
Data4 Top Data Data Data1 Bottom
c) Pop ( ) function: This function deletes an element from top of stack. *void ListStack::pop() { node temp; temp=top; if(top==NULL) cout<<"Stack UnderFlow"<<endl; else { cout<<"deleted Number from the stack ="; cout<<top->num; top=top->next; delete temp; } } d) Main( ) function: void main() { clrscr(); ListStack LS; int choice; do{ cout<<"Menu "<<endl; cout<<" 1 .Push" <<endl; cout<<" 2 .Pop"<<endl; cout<<" 3 .Show"<<endl; cout<<" 4 .EXIT"<<endl; cin>>choice; switch(choice){ case 1 : LS.push(); break; case 2 : LS.pop(); break; case 3 : LS.display(); break; } }while(choice!= 4 ); }
Write a program to compare opening and closing brackets in expression. This program takes an expression in the form of string and scan it character by character. Finally the output of the program is the valid or invalid expression. Algorithm: To do this comparison a stack ADT can be used to keep track of the scope delimiters encountered while scanning the expression.
Objectives: (c). Understand the applications of stacks (d). Implement stacks using both static and dynamic implementation Time Required: 3 hrs Software Required: (c). Windows OS (d). Microsoft Visual Studio
Write a C++ code to evaluate the infix expression without parenthesis given by user. Example: **3+4-5/ Infix String Operand Stack Operator Stack Value 3 3
- 3 4 + - 5 3 4 5 + - / 3 4 5 + - / 2 3 4 5 2 + - / 3 4 + - / 2 5 -> 5/2 , Push 2 3 4 2 + - 3 + - 2 4 -> 4-2, Push 2 3 2 + 5 + 2 3 -> 3+2, Push 5
17 CS 330 Operating Systems – Process
*rear = front; } else { rear->next=ptr; rear = ptr; } } d) Dequeue( ) Function: void DynQueue::dequeue() { queueNode temp; temp = front; if(isEmpty()) cout<<"Queue is Empty"; else { cout<<"data deleted="<<temp->num; front = front->next; delete temp; } }
Write a menu driven program to perform different operations with queue such aEnqueue ( ), Dequeue( ) and DisplayQueue( ).