HTTP is the protocol that governs communications between web servers and web clients (i.e. browsers). Part of the protocol includes a status code returned by the server to tell the browser the status of its most recent page request. Some of the codes and their meanings are listed below: 200, OK (fulfilled) 403, forbidden 404, not found 500, server error Given an int variable status , write a switch statement that prints out the appropriate label from the above list based on status .

LANGUAGE: C++

CHALLENGE:

HTTP is the protocol that governs communications between web servers and web clients (i.e. browsers). Part of the protocol includes a status code returned by the server to tell the browser the status of its most recent page request. Some of the codes and their meanings are listed below: 200, OK (fulfilled) 403, forbidden 404, not found 500, server error Given an int variable status , write a switch statement that prints out the appropriate label from the above list based on status.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

6 Comments

  1. Bobs on June 17, 2015 at 8:11 pm

    change cout to System.out.println(

  2. Ben Large on June 30, 2016 at 9:08 pm

    Here is the code for C:

    switch( status ){
    case 200:
    printf(“OK (fulfilled)”);
    break;
    case 403:
    printf(“forbidden”);
    break;
    case 404:
    printf(“not found”);
    break;
    case 500:
    printf(“server error”);
    break;
    }

  3. dick on October 27, 2016 at 12:45 am

    switch( status ){
    case 200:
    System.out.println(“OK (fulfilled)”);
    break;
    case 403:
    System.out.println(“forbidden”);
    break;
    case 404:
    System.out.println(“not found”);
    break;
    case 500:
    System.out.println(“server error”);
    break;
    }

    • Deepak Suri on March 15, 2017 at 7:23 pm

      I tried to use the above commands…but I keep on getting an error message:

      CODELAB ANALYSIS: COMPILER ERROR(S)

      More Hints:
      ⇒ You almost certainly should be using: “

  4. Hasseb on December 7, 2016 at 4:19 pm

    Could you please solve this question in python?

    Thanks

  5. SHABIR SHAHRAM on March 28, 2017 at 7:42 pm

    switch( status ){
    case 200:
    System.out.println( “OK (fulfilled)” );
    break;
    case 403:
    System.out.println( “forbidden” );
    break;
    case 404:
    System.out.println( “not found” );
    break;
    case 500:
    System.out.println( “server error” );
    break;
    }

Leave a Comment

You must be logged in to post a comment.