CODE SSEMS TO BE WORKING FINE FOR THE SAMPLE INPUT.BUT MLE IS SHOWING FOR HIDDEN TEST CASES

#include
#include
using namespace std;

int main()
{
stack s;
int q;
int n;
int c;
cin>>q;
while(q>0)
{
cin>>n;
if(n==2)
{
cin>>c;
s.push©;
}
if(n==1)
{
cout<<s.top()<<endl;
s.pop();
}
q–;
}
}

hi @Mukul-Shane-1247687648773500,
If the pile is empty, print “No Code” is missing read the question

Now have corrected that part but its now showing wrong answer.

#include #include using namespace std; int main() { stack s; int q; int n; int c; cin>>q; while(q>0) { cin>>n; if(n==2) { cin>>c; s.push©; } if(n==1) { if(!s.empty()) { cout<<s.top()<<endl; s.pop(); } else cout<<“No Code”; } q–; } }

#include #include using namespace std; int main() { stack s; int q; int n; int c; cin>>q; while(q>0) { cin>>n; if(n==2) { cin>>c; s.push©; } if(n==1) { if(!s.empty()) { cout<<s.top()<<endl; s.pop(); } else { if(q>0) { cout<<“No Code”; break; } else cout<<“No Code”; } } q–; } }

hi @Mukul-Shane-1247687648773500 actually i dont have the question with me let me ask for it from team will get back to u soon… sorry for the delay…till then keep doing other question ill help u with this dont worry

Sir here is the Question.Kartik sir loves coding. Hence, he took up the position of an instructor and founded Coding Blocks, a startup that serves students with awesome code modules. It is a very famous place and students are always queuing up to have one of those modules. Each module has a cost associated with it. The modules are kept as a pile. The job of an instructor is very difficult. He needs to handle two types of queries: 1) Student Query: When a student demands a module, the code module on the top of the pile is given and the student is charged according to the cost of the module. This reduces the height of the pile by 1. In case the pile is empty, the student goes away empty-handed. 2) Instructor Query: Sir prepares a code module and adds it on top of the pile. And reports the cost of the module. Help him manage this process. Input Format First line contains an integer Q, the number of queries. Q lines follow. A Type-1 ( Student ) Query, is indicated by a single integer 1 in the line. A Type-2 ( Instructor ) Query, is indicated by two space separated integers 2 and C (cost of the module prepared) . Constraints Q < 10^5 Output Format For each Type-1 Query, output the price that student has to pay i.e. cost of the module given to the customer in a new line. If the pile is empty, print “No Code” (without the quotes). Sample Input 7 2 73 2 83 2 43 1 1 2 16 2 48 Sample Output 43 83 Explanation Iteration 1 : Input : 2 73 Stack : 73 <- Top Iteration 2 : Input : 2 83 Stack : 73, 83 <- Top Iteration 3 : Input : 2 43 Stack : 73, 83,43 <- Top Iteration 4 : Input : 1 Print and pop 43 Stack : 73, 83 <- Top Iteration 5 : Input : 1 Print and pop 83 Stack : 73 <- Top Iteration 6 : Input : 2 16 Stack : 73, 16 <- Top Iteration 7 : Input : 2 48 Stack : 73, 16, 48 <- Top

Sir, can you now please get back to me on this question?

hi @Mukul-Shane-1247687648773500 updated https://ide.codingblocks.com/s/666548 thats waht i told in the correction

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.