CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 26

Threaded View

  1. #1
    Join Date
    Feb 2008
    Location
    Virginia
    Posts
    109

    Question Function problem

    I am trying to make a function that repeats till I say exit out. For some strange reason it's complaining about the answers.

    Code:
    Code:
    int add()
    {
            char answer;
            int a,b;
            int total;
    
            do
            {
                    std::cout<<"Enter two numbers: ";
                    std::cin>>a,b;
    
                    total = a+b;
                    std::cout<< total <<"\n\n";
                    std::cout<<"Do you wish to continue: Y/N";
                    std::cin>>answer;
            } while (answer = y || answer = Y);
    
            std::cout<<"Returning to menu\n\n";
            return 0;
    }
    Error:

    Code:
    In file included from index.cpp:2:0:
    functions.cpp: In function &#226;int add()&#226;:
    functions.cpp:9:11: error: &#226;y&#226; was not declared in this scope
    functions.cpp:20:34: error: &#226;Y&#226; was not declared in this scope
    Last edited by fuzzylr; May 3rd, 2011 at 03:50 PM.
    Sean
    Programing 1
    Programing 2 (Spring this year)
    Eager Game Developer.

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

Featured