NO output for if statments

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
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
Nov 10th, 2009
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,466
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 189
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso
 
0
  #2
Nov 10th, 2009
Change the && to ||
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle.
2) Problem 2[b]solved by : jonsca
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: 1
ebrutekim's Avatar
ebrutekim ebrutekim is offline Offline
Newbie Poster
 
0
  #3
Nov 10th, 2009
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
Nov 11th, 2009
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
Nov 11th, 2009
  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.
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 228 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC