Thread: switch case in algorithm form

  1. #1
    nehal
    Guest

    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
    nehal
    Guest
    pseuodo code.
    like writing the code but in english.

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    583
    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
    733
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

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