switch case in algorithm form

This is a discussion on switch case in algorithm form within the C Programming forums, part of the General Programming Boards category; hey guys my switch case is something like : Code: case 'a': printf("Enter Name: \n"); break; case 'b': printf("Enter Tutorial ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    11

    switch case in algorithm form

    hey guys my switch case is something like :
    Code:
            case 'a':
                printf("Enter Name: \n");
                break;
    
            case 'b':
                printf("Enter Tutorial time: \n");
                break;
    how would i write this in algorithm form?

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    90
    What do you mean by "algorithm form"?

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    11
    pseuodo code.
    like writing the code but in english.

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    535
    I don't think there's any formal definition of what pseudocode is meant to look like. So long as it explains what you're trying to do at that point in the program... fine, in my opinion.

    I'd just remove the very C-style parts (e.g. printf) and would write something like:

    Code:
            switch(blah)
            {
            case 'a':
                print "Enter Name: "
            case 'b':
                print "Enter Tutorial time: "
             }
    Obviously if you have any clever fall-throughs in the switch statement then you should write the breaks in the pseudocode. But it should just be a basic description of what you want to do.

  5. #5
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    682
    This does not look like a pseudocode for me. I think you wanted a block scheme or something.
    Code:
    If input is a lower-case 'a' letter ask user to enter his name,
    if it is a lower-case 'b' letter ask for tutorial time.
    Otherwise, do nothing.
    I never put signature, but I decided to make an exception.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 08-30-2010, 10:26 AM
  2. How can I make this code more elegant?
    By ejohns85 in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2009, 09:55 AM
  3. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 04:25 PM
  4. Format Precision & Scale
    By mattnewtoc in forum C Programming
    Replies: 1
    Last Post: 09-16-2008, 11:34 AM
  5. error with code
    By duffy in forum C Programming
    Replies: 8
    Last Post: 10-22-2002, 10:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21