Page 1 of 1

Q1) Find the output of the following C++ program. You should write the full explanation not just the final output. (4 po

Posted: Thu Jun 02, 2022 8:10 am
by answerhappygod
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 1
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 1 (20.38 KiB) Viewed 13 times
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 2
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 2 (16.69 KiB) Viewed 13 times
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 3
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 3 (21.75 KiB) Viewed 13 times
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 4
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 4 (15.9 KiB) Viewed 13 times
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 5
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 5 (16.94 KiB) Viewed 13 times
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 6
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 6 (22.83 KiB) Viewed 13 times
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 7
Q1 Find The Output Of The Following C Program You Should Write The Full Explanation Not Just The Final Output 4 Po 7 (22.83 KiB) Viewed 13 times
Q1) Find the output of the following C++ program. You should write the full explanation not just the final output. (4 points) #include <iostream> using namespace std; class Stack private: } int top; int arr[5]; Stack() { top = -1; public: for (int i = 0; i < 5; i++) ( } bool isEmpty(){ if (top== -1) else arr = 0; } return true; return false; bool isFull(){ if (top==4) else return true; return false;
} vold push(int val) ( if (isFull)) (cout ex'stack overflow: else ( top ++; arr[top] = val; } int pop() { if (isEmpty()) ( cout << " stack underflow" << endl; return 0; } else ( int popvalue = arr[top]; arr [top] = 0; top --; return popvalue; } int gettop(){ return arr[top]; } }; class Queue ( private: int front; int rear; int arr[5]; public: Queue() { front = -1; rear = = -1; for (int i = 0; i < 5; i++) {
} } arri], 1 bool isEmpty(){ if (front-1 && rear ==-1) return true, else return false; bool isFull) { if (rear 4) return true; else return false; } void enqueueint val) { if(isFull()) { cout << "Queue full << end; return; } else if (isEmpty()) { rear = 0; front = 0; arr[rear] =val; } else { rear++; arr[rear] = val; } int dequeue(){ int x = 0; if (isEmpty()) { cout << "Queue is Empty" << endl; return x; } else if (rear == front) { x = arr[rear]; rear= -1; front = -1; return x; } else { front);
WHEN 1 inge ( h boal checkdortedist, Queue & ( Stack st int expected 1 int frt; while (laistmpty) ( fnt agetfront) dequeue ( if that expected expected++; > else ( if (st. IsEmpty 0) { st.push(fnt): else if (Ist.isEmpty) &&st.gettop() <fnt) { return false; } else st.push(fnt); while (Ist.isEmpty() && st.gettop() expected) ( st.pop(); expected++; } if (expected-1 == n && st.isEmpty()) return true;
( im() 4 crueve 1500 & spate (21 a movese (3) que int if checkered "Yes" cout<<x"Wor") return f fo expected
return false; } int main() { Queue q q. enqueue (5) q. enqueue (1); q. enqueue (2): q. enqueue (3); q. enqueue (4): int n-qsize(): if (checkSorted(n, q)) cout << "Yes"; else cout<<"No": return 0; fnt expected st