c++ help

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 8
Reputation: justinlake888 is an unknown quantity at this point 
Solved Threads: 0
justinlake888 justinlake888 is offline Offline
Newbie Poster

c++ help

 
0
  #1
Oct 6th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 449
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 70
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: c++ help

 
0
  #2
Oct 6th, 2008
  1. if(!Continue())
  2. {
  3. cout << "bye" <<endl;
  4. }

is this what you want?
thanks
-chandra
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 118
Reputation: chococrack is on a distinguished road 
Solved Threads: 14
chococrack's Avatar
chococrack chococrack is offline Offline
Junior Poster

Re: c++ help

 
0
  #3
Oct 6th, 2008
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.
I would love to change the world, but they won't give me the source code
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 8
Reputation: justinlake888 is an unknown quantity at this point 
Solved Threads: 0
justinlake888 justinlake888 is offline Offline
Newbie Poster

Re: c++ help

 
0
  #4
Oct 6th, 2008
thanks
Last edited by justinlake888; Oct 6th, 2008 at 10:13 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 8
Reputation: justinlake888 is an unknown quantity at this point 
Solved Threads: 0
justinlake888 justinlake888 is offline Offline
Newbie Poster

Re: c++ help

 
0
  #5
Oct 7th, 2008
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 ().
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 305
Reputation: stilllearning has a spectacular aura about stilllearning has a spectacular aura about 
Solved Threads: 43
stilllearning stilllearning is offline Offline
Posting Whiz

Re: c++ help

 
0
  #6
Oct 7th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC