157k views
2 votes
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, on a line by itself, the appropriate label from the above list based on status.

1 Answer

4 votes

// Making a function that will take a integer as argument and return print the code

void Print(int statuscode){

// starting the switch statement on the interger sent

switch(statuscode)

case 200: // for case 200

cout << "Ok,Fullfilled"<< endl;

case 403: // for case 403

cout << "Forbidden" << endl;

case 404: // for case 404

cout << "Not Found" <<endl;

case 500: // for case 500

cout << "Server Error "<< endl;

default: // default case

cout << " Wrong code"<<endl;

}

User Matei Radu
by
5.6k points