NO output for if statments

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

Join Date: Nov 2009
Posts: 2
Reputation: fraandres is an unknown quantity at this point 
Solved Threads: 0
fraandres fraandres is offline Offline
Newbie Poster

NO output for if statments

 
0
  #1
20 Days Ago
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
  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. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,180
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 147
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster
 
0
  #2
20 Days Ago
Change the && to ||
I give up! 
1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...
3) What is the 123456789 prime numer?
Ask4Answer
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 6
Reputation: ebrutekim is an unknown quantity at this point 
Solved Threads: 0
ebrutekim's Avatar
ebrutekim ebrutekim is offline Offline
Newbie Poster
 
0
  #3
19 Days Ago
Just backing up what firstPerson said. && should be ||
"Don't be afraid to give your best to what seemingly are small jobs. Every time you conquer one it makes you that much stronger. If you do the little jobs well, the big ones will tend to take care of themselves." - Dale Carnegie

\m/
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 7
Reputation: alg is an unknown quantity at this point 
Solved Threads: 3
alg alg is offline Offline
Newbie Poster
 
0
  #4
19 Days Ago
Hi,

Use "or" not "and" in if statement

  1. if(size == 's' || size == 'S')
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 7
Reputation: alg is an unknown quantity at this point 
Solved Threads: 3
alg alg is offline Offline
Newbie Poster
 
0
  #5
19 Days Ago
  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; 19 Days Ago at 5:24 am.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC