Results 1 to 2 of 2

Thread: do while loop problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    do while loop problem

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

    Code:
    // 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??
    There is no achievement without goals

  2. #2
    Hyperactive Member Aash's Avatar
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    491

    Re: do while loop problem

    in your code, you're not providing function definition of evaluateexp..
    an example:
    Code:
    #include <iostream>
    
    using namespace std;
     
     
    int main ()
    {
        char word[100];
    
        char ch='Y';
        
        while(ch=='Y' || ch=='y')
        {
    		cout << "Enter postfix expression to evaluate:" << endl << endl;
    		cin >> word;
    		cout << word;
    
    		cout << "Do you want to enter word? [Y/N]" << endl << endl;
    		cin >> ch;
      
        }
       
     return 0;
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width