943,816 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 592
  • C++ RSS
Oct 6th, 2008
0

c++ help

Expand Post »
I am working on a code and I want it to ask if I want it to enter another number... when I hit "y OR Y" it repeats but the code. I don't know how to make it output "bye" when I type "N or n". Can someone please help me? Thanks.


this is part of the code that I have for Y/y which is working but I need to output something for N/n.

bool Continue()
{
char decision;
cout<<"\nDo you want to enter another number?(Y/N):";
cin >> decision;
return (decision=='y')||(decision=='Y');
}
Last edited by justinlake888; Oct 6th, 2008 at 2:05 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
justinlake888 is offline Offline
8 posts
since Sep 2008
Oct 6th, 2008
0

Re: c++ help

C++ Syntax (Toggle Plain Text)
  1. if(!Continue())
  2. {
  3. cout << "bye" <<endl;
  4. }

is this what you want?
Featured Poster
Reputation Points: 431
Solved Threads: 116
Practically a Master Poster
Agni is offline Offline
654 posts
since Dec 2007
Oct 6th, 2008
0

Re: c++ help

if (!Continue())

is the same as saying

if (Continue() != true)

is the same as saying

if (not Y/y)
Last edited by chococrack; Oct 6th, 2008 at 4:02 am.
Reputation Points: 92
Solved Threads: 16
Junior Poster
chococrack is offline Offline
149 posts
since Oct 2008
Oct 6th, 2008
0

Re: c++ help

thanks
Last edited by justinlake888; Oct 6th, 2008 at 10:13 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
justinlake888 is offline Offline
8 posts
since Sep 2008
Oct 7th, 2008
0

Re: c++ help

How do you get a program to work without using a global variable? I looked up a global variable and I just thought it meant when the variable is outside of int ().
Reputation Points: 10
Solved Threads: 0
Newbie Poster
justinlake888 is offline Offline
8 posts
since Sep 2008
Oct 7th, 2008
0

Re: c++ help

A global variable is a variable that you can access from every scope. That is, you would normally define it outside any function, and all of your functions would have access to it

Local variables are defined it inside your function, and are passed as an argument to any other functions that might need access to them.
Reputation Points: 161
Solved Threads: 43
Posting Whiz
stilllearning is offline Offline
309 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: storing a directory location
Next Thread in C++ Forum Timeline: Need help in Overloading << and >> operator





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC