{"id":1797,"date":"2016-09-24T11:50:44","date_gmt":"2016-09-24T11:50:44","guid":{"rendered":"http:\/\/tutorialsclass.com\/?post_type=exercise&#038;p=1797"},"modified":"2021-04-28T19:55:20","modified_gmt":"2021-04-28T19:55:20","slug":"write-program-show-day-week-using-switch","status":"publish","type":"exercise","link":"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/","title":{"rendered":"Write a program to show day of the week using switch"},"content":{"rendered":"\n<p><strong>Description: <\/strong><\/p>\n\n\n\n<p>Write a program to show day of the week (for example: Monday) based on numbers using switch\/case statements.<\/p>\n\n\n\n<p><strong>Conditions:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>You can pass 1 to 7 number in switch<\/li><li>Day 1 will be considered as Monday<\/li><li>If number is not between 1 to 7, show invalid number in default<\/li><\/ul>\n\n\n\n<p><strong> View Solution\/Program <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code language-php\"><code>&lt;?php\n$day = \"5\";\n \nswitch ($day) {\n    case \"1\":\n        echo \"It is Monday!\";\n        break;\n    case \"2\":\n        echo \"It is today!\";\n        break;\n    case \"3\":\n        echo \"It is Wednesday!\";\n        break;\n\tcase \"4\":\n        echo \"It is Thursday!\";\n        break;\n    case \"5\":\n        echo \"It is Friday!\";\n        break;\n    case \"6\":\n        echo \"It is Saturday!\";\n        break;\n\tcase \"7\":\n        echo \"It is Sunday!\";\n        break;\n    default:\n        echo \"Invalid number!\";\n}\n?><\/code><\/pre>\n\n\n\t<div class=\"tc-browser-container\">\r\n\t\t<div class=\"top\">\r\n\t\t\t<span class=\"tc-circle\"><\/span>\r\n\t\t\t<span class=\"tc-circle\"><\/span>\r\n\t\t\t<span class=\"tc-circle\"><\/span>\r\n\t\t\t<span class=\"tc-browser-title\"> Tutorials Class - Output Window <\/span>\r\n\t\t<\/div>\r\n\t\t<div class=\"tc-browser-content\"> <p>\nIt is Friday!<\/p>\n <\/div>\r\n\t<\/div>\r\n\n","protected":false},"excerpt":{"rendered":"<p>Description: Write a program to show day of the week (for example: Monday) based on numbers using switch\/case statements. Conditions: You can pass 1 to 7 number in switch Day 1 will&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"exercise_type":[126,88],"keywords":[68],"class_list":["post-1797","exercise","type-exercise","status-publish","hentry","exercise_type-php-all-exercises-assignments","exercise_type-php","keywords-decision-making"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Write a program to show day of the week using switch - Exercise - Tutorials Class<\/title>\n<meta name=\"description\" content=\"Write a program to show day of the week using switch - Exercise &amp; Assignments with Solution\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Write a program to show day of the week using switch - Exercise - Tutorials Class\" \/>\n<meta property=\"og:description\" content=\"Write a program to show day of the week using switch - Exercise &amp; Assignments with Solution\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorials Class\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/tutorialsclass\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-28T19:55:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/\",\"url\":\"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/\",\"name\":\"Write a program to show day of the week using switch - Exercise - Tutorials Class\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/#website\"},\"datePublished\":\"2016-09-24T11:50:44+00:00\",\"dateModified\":\"2021-04-28T19:55:20+00:00\",\"description\":\"Write a program to show day of the week using switch - Exercise & Assignments with Solution\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorialsclass.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exercises\",\"item\":\"https:\/\/tutorialsclass.com\/exercise\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP Exercises\",\"item\":\"https:\/\/tutorialsclass.com\/exercises\/php\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"PHP All Exercises &amp; Assignments\",\"item\":\"https:\/\/tutorialsclass.com\/exercises\/php\/php-all-exercises-assignments\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Write a program to show day of the week using switch\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorialsclass.com\/#website\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"name\":\"Tutorials Class\",\"description\":\"Online Tutorials for Beginners\",\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorialsclass.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/tutorialsclass.com\/#organization\",\"name\":\"Tutorials Class\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"contentUrl\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"width\":442,\"height\":94,\"caption\":\"Tutorials Class\"},\"image\":{\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/tutorialsclass\",\"https:\/\/x.com\/TutorialsClass\",\"https:\/\/in.pinterest.com\/merientinfotech\/boards\/\",\"https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Write a program to show day of the week using switch - Exercise - Tutorials Class","description":"Write a program to show day of the week using switch - Exercise & Assignments with Solution","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/","og_locale":"en_US","og_type":"article","og_title":"Write a program to show day of the week using switch - Exercise - Tutorials Class","og_description":"Write a program to show day of the week using switch - Exercise & Assignments with Solution","og_url":"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/","og_site_name":"Tutorials Class","article_publisher":"https:\/\/www.facebook.com\/tutorialsclass","article_modified_time":"2021-04-28T19:55:20+00:00","og_image":[{"width":600,"height":600,"url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@TutorialsClass","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/","url":"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/","name":"Write a program to show day of the week using switch - Exercise - Tutorials Class","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/#website"},"datePublished":"2016-09-24T11:50:44+00:00","dateModified":"2021-04-28T19:55:20+00:00","description":"Write a program to show day of the week using switch - Exercise & Assignments with Solution","breadcrumb":{"@id":"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tutorialsclass.com\/exercise\/write-program-show-day-week-using-switch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorialsclass.com\/"},{"@type":"ListItem","position":2,"name":"Exercises","item":"https:\/\/tutorialsclass.com\/exercise\/"},{"@type":"ListItem","position":3,"name":"PHP Exercises","item":"https:\/\/tutorialsclass.com\/exercises\/php\/"},{"@type":"ListItem","position":4,"name":"PHP All Exercises &amp; Assignments","item":"https:\/\/tutorialsclass.com\/exercises\/php\/php-all-exercises-assignments\/"},{"@type":"ListItem","position":5,"name":"Write a program to show day of the week using switch"}]},{"@type":"WebSite","@id":"https:\/\/tutorialsclass.com\/#website","url":"https:\/\/tutorialsclass.com\/","name":"Tutorials Class","description":"Online Tutorials for Beginners","publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorialsclass.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/tutorialsclass.com\/#organization","name":"Tutorials Class","url":"https:\/\/tutorialsclass.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/","url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","contentUrl":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","width":442,"height":94,"caption":"Tutorials Class"},"image":{"@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/tutorialsclass","https:\/\/x.com\/TutorialsClass","https:\/\/in.pinterest.com\/merientinfotech\/boards\/","https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA"]}]}},"_links":{"self":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/exercise\/1797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/exercise"}],"about":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/types\/exercise"}],"author":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/comments?post=1797"}],"version-history":[{"count":5,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/exercise\/1797\/revisions"}],"predecessor-version":[{"id":6735,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/exercise\/1797\/revisions\/6735"}],"wp:attachment":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/media?parent=1797"}],"wp:term":[{"taxonomy":"exercise_type","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/exercise_type?post=1797"},{"taxonomy":"keywords","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/keywords?post=1797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}