944,043 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 600
  • C++ RSS
Nov 10th, 2009
0

NO output for if statments

Expand Post »
why when I run it ....the output of the "if" statements doesn't come up ...Im trying to see if theres any erros but I just cant find anything please any help I would appreciated
C++ Syntax (Toggle Plain Text)
  1. include <iostream>
  2. #include<iomanip>
  3. using namespace std;
  4. int main()
  5. {
  6.  
  7. char size;
  8. cout<<"******************Welcome to M&D Pizza House*****************\n";
  9. cout<<" What size pizza do you want ? (s = small; m = medium; l = large): ";
  10. cin>>size;
  11.  
  12. if(size == 's' && size == 'S')
  13.  
  14. cout<<" Size: Small";
  15.  
  16. else if (size == 'm' && size == 'M')
  17. cout<<" Size: Medium";
  18.  
  19. else if(size == 'l' && size == 'L')
  20. cout<<" Size: Large";
  21.  
  22. return 0;
  23. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fraandres is offline Offline
7 posts
since Nov 2009
Nov 10th, 2009
0
Re: NO output for if statments
Change the && to ||
Reputation Points: 840
Solved Threads: 594
Senior Poster
firstPerson is offline Offline
3,864 posts
since Dec 2008
Nov 10th, 2009
0
Re: NO output for if statments
Just backing up what firstPerson said. && should be ||
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ebrutekim is offline Offline
6 posts
since Aug 2009
Nov 11th, 2009
0
Re: NO output for if statments
Hi,

Use "or" not "and" in if statement

C++ Syntax (Toggle Plain Text)
  1. if(size == 's' || size == 'S')
alg
Reputation Points: 10
Solved Threads: 3
Newbie Poster
alg is offline Offline
17 posts
since Oct 2009
Nov 11th, 2009
0
Re: NO output for if statments
C++ Syntax (Toggle Plain Text)
  1. if(size == 's' || size == 'S')
  2. cout<<" Size: Small";
  3.  
  4. else if (size == 'm' || size == 'M')
  5. cout<<" Size: Medium";
  6.  
  7. else if(size == 'l' || size == 'L')
  8. cout<<" Size: Large";
Last edited by alg; Nov 11th, 2009 at 5:24 am.
alg
Reputation Points: 10
Solved Threads: 3
Newbie Poster
alg is offline Offline
17 posts
since Oct 2009

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: Queue/ Stack problem
Next Thread in C++ Forum Timeline: Helpnwith linked lists





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


Follow us on Twitter


© 2011 DaniWeb® LLC