Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 12th, 2011, 11:52 PM
Registered User
 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default The switch statement

Dear All.


I'm a beginner who want to learn c++. I've ERROR message when I try to run the switch statement below, Really need you help guys. Thanks

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main ()
{
int choice(0); //store selection value here
cout << endl
<< "Please select the number below to load data to the variable\n\n"<< endl
<< endl << "1 mean"
<< endl << "2 Std"
<< endl << "3 Mode"
<< endl << "4 Middle"
<< endl << "5 Min"
<< endl << "6 Max"
<< endl << endl << "Enter your selection number :"; cin >> choice;
switch (choice)
{
case 1: cout << endl << "a" << endl;
break;
case 2: cout << endl << "b" << endl;
break;
case 3: cout << endl << "c" << endl;
break;
case 4: cout << endl << "d" << endl;
break;
case 5: cout << endl << "e" << endl;
break;
case 6: cout << endl << "f" << endl;
break;
default: cout << endl <<"You try enter a wrong number" << endl;
}
return 0;
}
Reply With Quote
  #2 (permalink)  
Old September 19th, 2011, 03:31 PM
MtD MtD is offline
Registered User
 
Join Date: Sep 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Works fine for me: http://www.ideone.com/LpO97
Please remember to include the exact error message in your post if you still encounter any errors, we're not mind-readers around here
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
switch statement crmpicco Javascript How-To 3 March 9th, 2015 10:37 PM
Switch-statement grstad C# 3 June 11th, 2008 06:53 AM
Using Switch statement in XHTML Lizane Java Basics 1 June 15th, 2007 06:46 AM
switch statement seymour_glass C# 5 January 24th, 2007 12:08 AM
C# switch statement nalla General .NET 4 December 14th, 2005 05:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.