Results 1 to 4 of 4

Thread: Correct Case Syntax

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    I've been doing too much basic. I can only remember the Basic syntax for Select Case. What is the right way in C++?
    I need better memorizational skills

  2. #2
    Guest
    Try the switch statement.

    Code:
    int nAge;
    cout << "Enter your Age";
    cin >> nAge;
    
    switch( nAge )
    {
    case 20:
    	cout << "Your are the same age as me";
    	break;
    case 90:
    	cout << "You are older than my grandpa";
    	break;
    case 50:
    	cout << "You are about the same as my parents";
    	break;
    }

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Use case default: for anything that doesn't fit the others.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Perfect. Thanks guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width