i have follwoing code in c++ .i want to continue it till suer give input as 'Y' or 'y'

// my first program in C++
 #include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
//#inlcude <iostream>
 #include <stdlib.h>
 #include <conio.h>
 #include <ctime>
 
using namespace std;
 
 
void Evaluatexp(char ch[]);
//void Evaluatexp(string ch);
int main ()
{
    char postfixexp[100];
//    string postfixexp;
    char ch='Y';
    //cout << "Hello World!" << endl << endl;
    
    while(ch=='Y' || ch=='y')
    {
    cout << "Enter postfix expression to evaluate:" << endl << endl;
    gets(postfixexp);
//cin >> postfixexp;
cout << (postfixexp);
    Evaluatexp(postfixexp);
    cout << "Do you want to enter another postfix expression to evaluate? [Y/N]" << endl << endl;
//    getch(ch);
   cin >> ch;
  cout << ch;
    
   }
   system("PAUSE");
 return 0;
}

but its not working fine ..and do not ask for expression in the code ( cout << "Enter postfix expression to evaluate:" << endl << endl

any help??

first You should use do while loop..
Second you should use "cin.ignore()" after getting character from user (Y/N)..
Try this following:

do
{
 // here is ur code
cin>>ch;
cin.ignore();
} while(ch=='Y' || ch=='y');

thanks for ur reply

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.